@Test public void testCleanupThrows() { HttpContentDecoder decoder = new HttpContentDecoder() { @Override protected EmbeddedChannel newContentDecoder(String contentEncoding) throws Exception { return new EmbeddedChannel(new ChannelInboundHandlerAdapter() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { ctx.fireExceptionCaught(new DecoderException()); ctx.fireChannelInactive(); } }); } }; final AtomicBoolean channelInactiveCalled = new AtomicBoolean(); EmbeddedChannel channel = new EmbeddedChannel(decoder, new ChannelInboundHandlerAdapter() { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { assertTrue(channelInactiveCalled.compareAndSet(false, true)); super.channelInactive(ctx); } }); assertTrue(channel.writeInbound(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/"))); HttpContent content = new DefaultHttpContent(Unpooled.buffer().writeZero(10)); assertTrue(channel.writeInbound(content)); assertEquals(1, content.refCnt()); try { channel.finishAndReleaseAll(); fail(); } catch (CodecException expected) { } assertTrue(channelInactiveCalled.get()); assertEquals(0, content.refCnt()); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cleanupSafely(ctx); super.channelInactive(ctx); }
HttpContentDecoder extends MessageToMessageDecoder<HttpObject> { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cleanupSafely(ctx); super.channelInactive(ctx); } }
HttpContentDecoder extends MessageToMessageDecoder<HttpObject> { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cleanupSafely(ctx); super.channelInactive(ctx); }  }
HttpContentDecoder extends MessageToMessageDecoder<HttpObject> { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cleanupSafely(ctx); super.channelInactive(ctx); }  @Override void handlerRemoved(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void handlerAdded(ChannelHandlerContext ctx); }
HttpContentDecoder extends MessageToMessageDecoder<HttpObject> { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cleanupSafely(ctx); super.channelInactive(ctx); }  @Override void handlerRemoved(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void handlerAdded(ChannelHandlerContext ctx);  }