Merge "Close FileChannels in UpdateHandler#copyFile." into nyc-dev

am: fce8ed98aa

* commit 'fce8ed98aa738a13332b6ccc9c5b145f17fae51f':
  Close FileChannels in UpdateHandler#copyFile.
main
Keisuke Kuroyanagi 2016-02-25 04:25:24 +00:00 committed by android-build-merger
commit 14ff0a66f0
1 changed files with 10 additions and 2 deletions

View File

@ -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");