Skip to content

Commit

Permalink
LzmaFrameEncoderTest leak due to LzmaInputStream close behavior
Browse files Browse the repository at this point in the history
Motivation:
c1932a8 made an assumption that the LzmaInputStream which wraps a ByteBufInputStream would delegate the close operation to the wrapped stream. This assumption is not true and thus we still had a leak. An issue has been logged with our LZMA dependency jponge/lzma-java#14.

Modifications:
- Force a close on the wrapped stream

Result:
No more leak.
  • Loading branch information
Scottmitch authored and liuzhengyang committed Sep 10, 2017
1 parent b42a7ce commit 033b9a3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ protected ByteBuf decompress(ByteBuf compressed, int originalLength) throws Exce
} finally {
if (lzmaIs != null) {
lzmaIs.close();
} else {
}
// LzmaInputStream does not close the stream it wraps, so we should always close.
// The close operation should be safe to call multiple times anyways so lets just call it and be safe.
// https://github.com/jponge/lzma-java/issues/14
if (is != null) {
is.close();
}
}
Expand Down

0 comments on commit 033b9a3

Please sign in to comment.