End deflater properly in orc writer
Make sure end() is called to prevent native memory leak.
@@ -42,7 +42,7 @@ public class DeflateCompressor
}
Deflater deflater = new Deflater(COMPRESSION_LEVEL, true);
-
+ try {
deflater.setInput(input, inputOffset, inputLength);
deflater.finish();
@@ -50,9 +50,12 @@ public class DeflateCompressor
if (!deflater.finished()) {
throw new IllegalStateException("maxCompressedLength formula is incorrect, because deflate produced more data");
}
- deflater.end();
return compressedDataLength;
}
+ finally {
+ deflater.end();
+ }
+ }
@Override
public void compress(ByteBuffer input, ByteBuffer output)
