Fix buffer leak in test which was introduced while implement ZLIB_OR_NONE support. Related to [#2269]
This commit is contained in:
parent
f62012cba5
commit
99995876dc
@ -58,8 +58,7 @@ public abstract class ZlibTest {
|
|||||||
deflatedData.release();
|
deflatedData.release();
|
||||||
buf.release();
|
buf.release();
|
||||||
} finally {
|
} finally {
|
||||||
// close channel to prevent any leak even on exception
|
dispose(chDecoderGZip);
|
||||||
chDecoderGZip.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +110,8 @@ public abstract class ZlibTest {
|
|||||||
|
|
||||||
data.release();
|
data.release();
|
||||||
} finally {
|
} finally {
|
||||||
// close channels in all cases to guard against leak when exception was thrown
|
dispose(chEncoder);
|
||||||
chEncoder.close();
|
dispose(chDecoderZlib);
|
||||||
chDecoderZlib.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,12 +146,29 @@ public abstract class ZlibTest {
|
|||||||
|
|
||||||
assertFalse(chDecoderZlib.finish());
|
assertFalse(chDecoderZlib.finish());
|
||||||
} finally {
|
} finally {
|
||||||
// close channels in all cases to guard against leak when exception was thrown
|
dispose(chEncoder);
|
||||||
chEncoder.close();
|
dispose(chDecoderZlib);
|
||||||
chDecoderZlib.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void dispose(EmbeddedChannel ch) {
|
||||||
|
if (ch.finish()) {
|
||||||
|
for (;;) {
|
||||||
|
Object msg = ch.readInbound();
|
||||||
|
if (msg == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ReferenceCountUtil.release(msg);
|
||||||
|
}
|
||||||
|
for (;;) {
|
||||||
|
Object msg = ch.readOutbound();
|
||||||
|
if (msg == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ReferenceCountUtil.release(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private void testCompressSmall(ZlibWrapper encoderWrapper, ZlibWrapper decoderWrapper) throws Exception {
|
private void testCompressSmall(ZlibWrapper encoderWrapper, ZlibWrapper decoderWrapper) throws Exception {
|
||||||
testCompress0(encoderWrapper, decoderWrapper, Unpooled.wrappedBuffer(BYTES_SMALL));
|
testCompress0(encoderWrapper, decoderWrapper, Unpooled.wrappedBuffer(BYTES_SMALL));
|
||||||
testCompress0(encoderWrapper, decoderWrapper,
|
testCompress0(encoderWrapper, decoderWrapper,
|
||||||
|
Loading…
Reference in New Issue
Block a user