You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2013/11/26 23:24:22 UTC

svn commit: r1545867 - /hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java

Author: eclark
Date: Tue Nov 26 22:24:22 2013
New Revision: 1545867

URL: http://svn.apache.org/r1545867
Log:
HBASE-10035 Fix Potential Resource Leak in IPCUtils

Modified:
    hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java

Modified: hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java?rev=1545867&r1=1545866&r2=1545867&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java (original)
+++ hbase/branches/0.96/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java Tue Nov 26 22:24:22 2013
@@ -170,10 +170,11 @@ class IPCUtil {
       CompressionInputStream cis =
         compressor.createInputStream(new ByteArrayInputStream(cellBlock, offset, length),
         poolDecompressor);
+      ByteBufferOutputStream bbos = null;
       try {
         // TODO: This is ugly.  The buffer will be resized on us if we guess wrong.
         // TODO: Reuse buffers.
-        ByteBufferOutputStream bbos = new ByteBufferOutputStream((length - offset) *
+        bbos = new ByteBufferOutputStream((length - offset) *
           this.cellBlockDecompressionMultiplier);
         IOUtils.copy(cis, bbos);
         bbos.close();
@@ -181,6 +182,8 @@ class IPCUtil {
         is = new ByteArrayInputStream(bb.array(), 0, bb.limit());
       } finally {
         if (is != null) is.close();
+        if (bbos != null) bbos.close();
+
         CodecPool.returnDecompressor(poolDecompressor);
       }
     } else {