Source:
public void testIllegalStateWhenDecompressionInProgress() { WebSocketExtensionFilter selectivityDecompressionFilter = new WebSocketExtensionFilter() { @Override public boolean mustSkip(WebSocketFrame frame) { return frame.content().readableBytes() < 100; } }; EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel( new PerMessageDeflateDecoder(false, selectivityDecompressionFilter)); byte[] firstPayload = new byte[200]; random.nextBytes(firstPayload); byte[] finalPayload = new byte[50]; random.nextBytes(finalPayload); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(firstPayload))); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(finalPayload))); ByteBuf compressedFirstPayload = encoderChannel.readOutbound(); ByteBuf compressedFinalPayload = encoderChannel.readOutbound(); assertTrue(encoderChannel.finish()); BinaryWebSocketFrame firstPart = new BinaryWebSocketFrame(false, WebSocketExtension.RSV1, compressedFirstPayload); ContinuationWebSocketFrame finalPart = new ContinuationWebSocketFrame(true, WebSocketExtension.RSV1, compressedFinalPayload); assertTrue(decoderChannel.writeInbound(firstPart)); BinaryWebSocketFrame outboundFirstPart = decoderChannel.readInbound(); assertEquals(0, outboundFirstPart.rsv()); assertArrayEquals(firstPayload, ByteBufUtil.getBytes(outboundFirstPart.content())); assertTrue(outboundFirstPart.release()); decoderChannel.writeInbound(finalPart); }

Target:
public void testIllegalStateWhenDecompressionInProgress() { WebSocketExtensionFilter selectivityDecompressionFilter = new WebSocketExtensionFilter() { @Override public boolean mustSkip(WebSocketFrame frame) { return frame.content().readableBytes() < 100; } }; EmbeddedChannel encoderChannel = new EmbeddedChannel( ZlibCodecFactory.newZlibEncoder(ZlibWrapper.NONE, 9, 15, 8)); EmbeddedChannel decoderChannel = new EmbeddedChannel( new PerMessageDeflateDecoder(false, selectivityDecompressionFilter)); byte[] firstPayload = new byte[200]; random.nextBytes(firstPayload); byte[] finalPayload = new byte[50]; random.nextBytes(finalPayload); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(firstPayload))); assertTrue(encoderChannel.writeOutbound(Unpooled.wrappedBuffer(finalPayload))); ByteBuf compressedFirstPayload = encoderChannel.readOutbound(); ByteBuf compressedFinalPayload = encoderChannel.readOutbound(); assertTrue(encoderChannel.finishAndReleaseAll()); BinaryWebSocketFrame firstPart = new BinaryWebSocketFrame(false, WebSocketExtension.RSV1, compressedFirstPayload); ContinuationWebSocketFrame finalPart = new ContinuationWebSocketFrame(true, WebSocketExtension.RSV1, compressedFinalPayload); assertTrue(decoderChannel.writeInbound(firstPart)); BinaryWebSocketFrame outboundFirstPart = decoderChannel.readInbound(); assertEquals(0, outboundFirstPart.rsv()); assertArrayEquals(firstPayload, ByteBufUtil.getBytes(outboundFirstPart.content())); assertTrue(outboundFirstPart.release()); try { decoderChannel.writeInbound(finalPart); } finally { assertTrue(finalPart.release()); assertFalse(encoderChannel.finishAndReleaseAll()); } }