Repository: hadoop
Updated Branches:
  refs/heads/trunk 2f8e9b7e4 -> a853b4e1b


HDFS-11342. Fix FileInputStream leak in loadLastPartialChunkChecksum. 
Contributed by Chen Liang.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/a853b4e1
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/a853b4e1
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/a853b4e1

Branch: refs/heads/trunk
Commit: a853b4e1b5742faadf7b667b0cebbc0dac001395
Parents: 2f8e9b7
Author: Arpit Agarwal <a...@apache.org>
Authored: Mon Jan 16 13:45:22 2017 -0800
Committer: Arpit Agarwal <a...@apache.org>
Committed: Mon Jan 16 13:45:22 2017 -0800

----------------------------------------------------------------------
 .../hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java   | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a853b4e1/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
index 042ef6e..f6e6a59 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsVolumeImpl.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
 
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -1122,9 +1123,11 @@ public class FsVolumeImpl implements FsVolumeSpi {
   public byte[] loadLastPartialChunkChecksum(
       File blockFile, File metaFile) throws IOException {
     // readHeader closes the temporary FileInputStream.
-    DataChecksum dcs = BlockMetadataHeader
-        .readHeader(fileIoProvider.getFileInputStream(this, metaFile))
-        .getChecksum();
+    DataChecksum dcs;
+    try (FileInputStream fis = fileIoProvider.getFileInputStream(
+        this, metaFile)) {
+      dcs = BlockMetadataHeader.readHeader(fis).getChecksum();
+    }
     final int checksumSize = dcs.getChecksumSize();
     final long onDiskLen = blockFile.length();
     final int bytesPerChecksum = dcs.getBytesPerChecksum();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to