aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2016-02-24 20:08:27 -0800
committerKeisuke Kuroyanagi <ksk@google.com>2016-02-24 20:08:27 -0800
commit3e2670265e17e91c5a8cfff01711f973dccd2a0c (patch)
treed4f32855b2e8e0bcbfe0f93e4e1ebd51f417c460 /java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
parent706fce9bb0e044f281bf12742c406964b18e9190 (diff)
downloadlatinime-3e2670265e17e91c5a8cfff01711f973dccd2a0c.tar.gz
latinime-3e2670265e17e91c5a8cfff01711f973dccd2a0c.tar.xz
latinime-3e2670265e17e91c5a8cfff01711f973dccd2a0c.zip
Close FileChannels in UpdateHandler#copyFile.
Bug: 26239281 Change-Id: Ib30beb3548f8fb4a8e338b5da863ae28c252bc2b
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java')
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
index 0517bc814..6b32c684f 100644
--- a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
+++ b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java
@@ -689,8 +689,16 @@ public final class UpdateHandler {
} else {
try {
final FileChannel sourceChannel = ((FileInputStream) in).getChannel();
- final FileChannel destinationChannel = ((FileOutputStream) out).getChannel();
- sourceChannel.transferTo(0, Integer.MAX_VALUE, destinationChannel);
+ try {
+ final FileChannel destinationChannel = ((FileOutputStream) out).getChannel();
+ try {
+ sourceChannel.transferTo(0, Integer.MAX_VALUE, destinationChannel);
+ } finally {
+ destinationChannel.close();
+ }
+ } finally {
+ sourceChannel.close();
+ }
} catch (IOException e) {
// Can't work with channels, or something went wrong. Copy by hand.
DebugLogUtils.l("Won't work");