Skip to content

Commit 5c859ae

Browse files
committed
Fix OOM when importing too large dictionary file
If OOM is thrown when reading zip file, try to reset import state and return. As OOM has been thrown, recovering might not be enough; hope the fix works well. BUG= TEST= REF_BUG=27289195 REF_CL=115524102 REF_TIME=2016-02-25T13:34:01+09:00 REF_TIME_RAW=1456374841 +0900
1 parent 0fa9de4 commit 5c859ae

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/android/src/com/google/android/inputmethod/japanese/userdictionary/UserDictionaryToolActivity.java

+10
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ private void handleZipImportData(String path) {
308308
toastManager.showMessageShortly(
309309
R.string.user_dictionary_tool_error_import_cannot_read_import_source);
310310
model.resetImportState();
311+
} catch (OutOfMemoryError e) {
312+
// The zip file being imported is too large. Recovering (if possible).
313+
toastManager.showMessageShortly(
314+
R.string.user_dictionary_tool_error_import_too_large_zip_entry);
315+
model.resetImportState();
311316
} finally {
312317
if (zipFile != null) {
313318
MozcUtil.closeIgnoringIOException(zipFile);
@@ -578,6 +583,11 @@ public void onClick(DialogInterface dialog, int which) {
578583
R.string.user_dictionary_tool_error_import_cannot_read_import_source);
579584
model.resetImportState();
580585
return;
586+
} catch (OutOfMemoryError e) {
587+
toastManager.showMessageShortly(
588+
R.string.user_dictionary_tool_error_import_too_large_zip_entry);
589+
model.resetImportState();
590+
return;
581591
} finally {
582592
MozcUtil.closeIgnoringIOException(zipFile);
583593
}

src/android/static_resources/resources_oss/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
<string name="user_dictionary_tool_error_import_source_invalid_scheme">Data import only works on files.</string>
241241
<string name="user_dictionary_tool_error_import_cannot_read_import_source">Could not read the file.</string>
242242
<string name="user_dictionary_tool_error_import_no_zip_entry">The ZIP file is empty.</string>
243+
<string name="user_dictionary_tool_error_import_too_large_zip_entry" description="Shown when the user is importing too large ZIP file.">The ZIP file is too large.</string>
243244
<string name="user_dictionary_tool_error_export_no_exportable_applications">There are no applications (e.g. Google Docs) to export the user dictionary.</string>
244245
<string name="user_dictionary_tool_error_export_failed_to_export">Failed to export the user dictionary.</string>
245246
<string name="user_dictionary_tool_status_error_general">The operation has failed.</string>

src/mozc_version_template.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MAJOR=2
22
MINOR=17
3-
BUILD=2509
3+
BUILD=2510
44
REVISION=102
55
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
66
# downloaded by NaCl Mozc.

0 commit comments

Comments
 (0)