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:29 UTC

svn commit: r1545868 - /hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java

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

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

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

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java?rev=1545868&r1=1545867&r2=1545868&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java Tue Nov 26 22:24:29 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 {