Browse Source

HDFS-1990. Fix resource leaks in BlockReceiver.close(). Contributed by Uma Maheswara Rao G

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1143147 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 14 năm trước cách đây
mục cha
commit
5c778cdee3

+ 3 - 0
hdfs/CHANGES.txt

@@ -805,6 +805,9 @@ Trunk (unreleased changes)
     HDFS-2053. Bug in INodeDirectory#computeContentSummary warning.
     HDFS-2053. Bug in INodeDirectory#computeContentSummary warning.
     (Michael Noll via eli)
     (Michael Noll via eli)
 
 
+    HDFS-1990. Fix  resource leaks in BlockReceiver.close().  (Uma Maheswara
+    Rao G via szetszwo)
+
 Release 0.22.0 - Unreleased
 Release 0.22.0 - Unreleased
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 6 - 0
hdfs/src/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

@@ -231,6 +231,9 @@ class BlockReceiver implements Closeable, FSConstants {
     } catch(IOException e) {
     } catch(IOException e) {
       ioe = e;
       ioe = e;
     }
     }
+    finally {
+      IOUtils.closeStream(checksumOut);
+    }
     // close block file
     // close block file
     try {
     try {
       if (out != null) {
       if (out != null) {
@@ -244,6 +247,9 @@ class BlockReceiver implements Closeable, FSConstants {
     } catch (IOException e) {
     } catch (IOException e) {
       ioe = e;
       ioe = e;
     }
     }
+    finally{
+      IOUtils.closeStream(out);
+    }
     // disk check
     // disk check
     if(ioe != null) {
     if(ioe != null) {
       datanode.checkDiskError(ioe);
       datanode.checkDiskError(ioe);