HBASE-10037 Fix potential Resource Leak in EncodedDataBlock

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1545873 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
eclark 2013-11-26 22:30:42 +00:00
parent fc67c8a8b8
commit 3874bc7f09
1 changed files with 11 additions and 6 deletions

View File

@ -165,14 +165,19 @@ public class EncodedDataBlock {
if (compressor != null) { if (compressor != null) {
compressor.reset(); compressor.reset();
} }
OutputStream compressingStream = algo.createCompressionStream( OutputStream compressingStream = null;
try {
compressingStream = algo.createCompressionStream(
compressedStream, compressor, 0); compressedStream, compressor, 0);
compressingStream.write(inputBuffer, offset, length); compressingStream.write(inputBuffer, offset, length);
compressingStream.flush(); compressingStream.flush();
compressingStream.close();
return compressedStream.size(); return compressedStream.size();
} finally {
if (compressingStream != null) compressingStream.close();
}
} }
/** /**