diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-04-25 10:45:04 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-04-25 10:45:04 -0700 |
commit | 361f35b7b1fe758d93e0952536a298b2ed045a89 (patch) | |
tree | 27ae11d0487e541d4a76ac820af27cf78c406896 | |
parent | c387029cf67358eea21f9fd60e6cac60049839b7 (diff) | |
download | UserDictionaryProvider-l-preview.tar.gz |
Close stream after writing backup data.android-sdk-4.4.2_r1.0.1android-sdk-4.4.2_r1android-l-preview_r2android-cts-4.4_r4android-cts-4.4_r1android-4.4w_r1android-4.4_r1.2.0.1android-4.4_r1.2android-4.4_r1.1.0.1android-4.4_r1.1android-4.4_r1.0.1android-4.4_r1android-4.4_r0.9android-4.4_r0.8android-4.4_r0.7android-4.4.4_r2.0.1android-4.4.4_r2android-4.4.4_r1.0.1android-4.4.4_r1android-4.4.3_r1.1.0.1android-4.4.3_r1.1android-4.4.3_r1.0.1android-4.4.3_r1android-4.4.2_r2.0.1android-4.4.2_r2android-4.4.2_r1.0.1android-4.4.2_r1android-4.4.1_r1.0.1android-4.4.1_r1l-previewkitkat-wearkitkat-releasekitkat-mr2.2-releasekitkat-mr2.1-releasekitkat-mr2-releasekitkat-mr1.1-releasekitkat-mr1-releasekitkat-devkitkat-cts-releasekitkat-cts-devidea133-weekly-releaseidea133
Avoids leak.
Change-Id: I657044d1ecc98c021271dab486e104d74f60cc5c
-rw-r--r-- | src/com/android/providers/userdictionary/DictionaryBackupAgent.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/com/android/providers/userdictionary/DictionaryBackupAgent.java b/src/com/android/providers/userdictionary/DictionaryBackupAgent.java index 6432a01..d4bf885 100644 --- a/src/com/android/providers/userdictionary/DictionaryBackupAgent.java +++ b/src/com/android/providers/userdictionary/DictionaryBackupAgent.java @@ -41,6 +41,8 @@ import android.provider.UserDictionary.Words; import android.text.TextUtils; import android.util.Log; +import libcore.io.IoUtils; + /** * Performs backup and restore of the User Dictionary. */ @@ -156,8 +158,9 @@ public class DictionaryBackupAgent extends BackupAgentHelper { } byte[] sizeBytes = new byte[4]; ByteArrayOutputStream baos = new ByteArrayOutputStream(cursor.getCount() * 10); + GZIPOutputStream gzip = null; try { - GZIPOutputStream gzip = new GZIPOutputStream(baos); + gzip = new GZIPOutputStream(baos); while (!cursor.isAfterLast()) { String name = cursor.getString(COLUMN_WORD); int frequency = cursor.getInt(COLUMN_FREQUENCY); @@ -179,6 +182,7 @@ public class DictionaryBackupAgent extends BackupAgentHelper { Log.e(TAG, "Couldn't compress the dictionary:\n" + ioe); return EMPTY_DATA; } finally { + IoUtils.closeQuietly(gzip); cursor.close(); } return baos.toByteArray(); |