Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79d097ee authored by Henrik Baard's avatar Henrik Baard
Browse files

generateProjectThumbnail can fail to close output stream

In case of an excpetion the generateProjectThumbnail method
does not close the output stream used.

Move the closing of the stream to the finally block.

Change-Id: I417236ab1acf65bb97e40beb8a750035c25e436e
parent fa42e774
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ import android.os.Debug;
import android.os.SystemProperties;
import android.os.Environment;

import libcore.io.IoUtils;

/**
 * The VideoEditor implementation {@hide}
 */
@@ -1859,15 +1861,15 @@ public class VideoEditorImpl implements VideoEditor {
                }
            }

            FileOutputStream stream = null;
            try {
                FileOutputStream stream = new FileOutputStream(mProjectPath + "/"
                                                          + THUMBNAIL_FILENAME);
                stream = new FileOutputStream(mProjectPath + "/" + THUMBNAIL_FILENAME);
                projectBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                stream.flush();
                stream.close();
            } catch (IOException e) {
                throw new IllegalArgumentException ("Error creating project thumbnail");
            } finally {
                IoUtils.closeQuietly(stream);
                projectBitmap.recycle();
            }
        }