From 79d097ee5bd3281669b39419e1fa7aa2f5e96820 Mon Sep 17 00:00:00 2001 From: Henrik Baard Date: Thu, 11 Jul 2013 12:55:09 +0200 Subject: [PATCH] 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 --- media/java/android/media/videoeditor/VideoEditorImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java index 2446c2fd092f3..fbf2eaba7da7d 100644 --- a/media/java/android/media/videoeditor/VideoEditorImpl.java +++ b/media/java/android/media/videoeditor/VideoEditorImpl.java @@ -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(); } }