From a4ea35b875f9215aefb8b8c6c6b6c882987f856b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 16 Apr 2014 14:01:50 +0200 Subject: [PATCH] Fix missed buffer leaks in SpdyFrameDecoderTest Motivation: Fix leaks reported during running SpdyFrameDecoderTest Modifications: Make sure the produced buffers of SpdyFrameDecoder and SpdyFrameDecoderTest are released Result: No more leak reports during run the tests. --- .../handler/codec/spdy/SpdyFrameDecoderTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java index 51663d4e92..52aa5d7bc6 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/spdy/SpdyFrameDecoderTest.java @@ -104,7 +104,12 @@ public class SpdyFrameDecoderTest { @Override public void readHeaderBlock(ByteBuf headerBlock) { - delegate.readHeaderBlock(headerBlock); + try { + delegate.readHeaderBlock(headerBlock); + } finally { + // release the data after we delegate it and so checked it. + headerBlock.release(); + } } @Override @@ -430,14 +435,14 @@ public class SpdyFrameDecoderTest { int associatedToStreamId = RANDOM.nextInt() & 0x7FFFFFFF; byte priority = (byte) (RANDOM.nextInt() & 0x07); - ByteBuf buf = Unpooled.buffer(SPDY_HEADER_SIZE + length + headerBlockLength); + ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length + headerBlockLength)); encodeControlFrameHeader(buf, type, flags, length + headerBlockLength); buf.writeInt(streamId); buf.writeInt(associatedToStreamId); buf.writeByte(priority << 5); buf.writeByte(0); - ByteBuf headerBlock = Unpooled.buffer(headerBlockLength); + ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(headerBlockLength)); for (int i = 0; i < 256; i ++) { headerBlock.writeInt(RANDOM.nextInt()); }