Source:
<code>public void testSelectivityDecompressionSkip() { WebSocketExtensionFilter selectivityDecompressionFilter = new WebSocketExtensionFilter() { @Override public boolean mustSkip(WebSocketFrame frame) { return frame instanceof TextWebSocketFrame && frame.content().readableBytes() < 100; } }; EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel( new PerMessageDeflateDecoder(false, selectivityDecompressionFilter)); String textPayload = "compressed payload"; byte[] binaryPayload = new byte[300]; random.nextBytes(binaryPayload); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(textPayload.getBytes(UTF_8)))); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(binaryPayload))); ByteBuf compressedTextPayload = encoderChannel.readOutbound(); ByteBuf compressedBinaryPayload = encoderChannel.readOutbound(); TextWebSocketFrame compressedTextFrame = new TextWebSocketFrame(true, WebSocketExtension.RSV1, compressedTextPayload); BinaryWebSocketFrame compressedBinaryFrame = new BinaryWebSocketFrame(true, WebSocketExtension.RSV1, compressedBinaryPayload); assertTrue(decoderChannel.writeInbound(compressedTextFrame)); assertTrue(decoderChannel.writeInbound(compressedBinaryFrame)); TextWebSocketFrame inboundTextFrame = decoderChannel.readInbound(); BinaryWebSocketFrame inboundBinaryFrame = decoderChannel.readInbound(); assertEquals(WebSocketExtension.RSV1, inboundTextFrame.rsv()); assertEquals(compressedTextPayload, inboundTextFrame.content()); assertTrue(inboundTextFrame.release()); assertEquals(0, inboundBinaryFrame.rsv()); assertArrayEquals(binaryPayload, ByteBufUtil.getBytes(inboundBinaryFrame.content())); assertTrue(inboundBinaryFrame.release()); <START> assertTrue(encoderChannel.finish()); <END> assertFalse(decoderChannel.finish()); }</code><technical_language>call encoderChannel.finishAndReleaseAll() fix LEAK</technical_language>

Target:
public void testSelectivityDecompressionSkip() { WebSocketExtensionFilter selectivityDecompressionFilter = new WebSocketExtensionFilter() { @Override public boolean mustSkip(WebSocketFrame frame) { return frame instanceof TextWebSocketFrame && frame.content().readableBytes() < 100; } }; EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel( new PerMessageDeflateDecoder(false, selectivityDecompressionFilter)); String textPayload = "compressed payload"; byte[] binaryPayload = new byte[300]; random.nextBytes(binaryPayload); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(textPayload.getBytes(UTF_8)))); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(binaryPayload))); ByteBuf compressedTextPayload = encoderChannel.readOutbound(); ByteBuf compressedBinaryPayload = encoderChannel.readOutbound(); TextWebSocketFrame compressedTextFrame = new TextWebSocketFrame(true, WebSocketExtension.RSV1, compressedTextPayload); BinaryWebSocketFrame compressedBinaryFrame = new BinaryWebSocketFrame(true, WebSocketExtension.RSV1, compressedBinaryPayload); assertTrue(decoderChannel.writeInbound(compressedTextFrame)); assertTrue(decoderChannel.writeInbound(compressedBinaryFrame)); TextWebSocketFrame inboundTextFrame = decoderChannel.readInbound(); BinaryWebSocketFrame inboundBinaryFrame = decoderChannel.readInbound(); assertEquals(WebSocketExtension.RSV1, inboundTextFrame.rsv()); assertEquals(compressedTextPayload, inboundTextFrame.content()); assertTrue(inboundTextFrame.release()); assertEquals(0, inboundBinaryFrame.rsv()); assertArrayEquals(binaryPayload, ByteBufUtil.getBytes(inboundBinaryFrame.content())); assertTrue(inboundBinaryFrame.release()); assertTrue(encoderChannel.finishAndReleaseAll()); assertFalse(decoderChannel.finish()); }