@Test public void testInternalBufferClearReadAll() { final ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer().writeBytes(new byte[] {'a'})); EmbeddedChannel channel = new EmbeddedChannel(new ByteToMessageDecoder() { @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { ByteBuf byteBuf = internalBuffer(); assertEquals(1, byteBuf.refCnt()); in.readByte(); ctx.pipeline().remove(this); assertEquals(0, byteBuf.refCnt()); } }); assertFalse(channel.writeInbound(buf)); assertFalse(channel.finish()); }
protected ByteBuf internalBuffer() { if (cumulation != null) { return cumulation; } else { return Unpooled.EMPTY_BUFFER; } }
ByteToMessageDecoder extends ChannelInboundHandlerAdapter { protected ByteBuf internalBuffer() { if (cumulation != null) { return cumulation; } else { return Unpooled.EMPTY_BUFFER; } } }
ByteToMessageDecoder extends ChannelInboundHandlerAdapter { protected ByteBuf internalBuffer() { if (cumulation != null) { return cumulation; } else { return Unpooled.EMPTY_BUFFER; } } protected  ByteToMessageDecoder(); }
ByteToMessageDecoder extends ChannelInboundHandlerAdapter { protected ByteBuf internalBuffer() { if (cumulation != null) { return cumulation; } else { return Unpooled.EMPTY_BUFFER; } } protected  ByteToMessageDecoder(); void setSingleDecode(boolean singleDecode); boolean isSingleDecode(); void setCumulator(Cumulator cumulator); void setDiscardAfterReads(int discardAfterReads); @Override final void handlerRemoved(ChannelHandlerContext ctx); static void main(String[] args); @Override void channelRead(ChannelHandlerContext ctx, Object msg); @Override void channelReadComplete(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void userEventTriggered(ChannelHandlerContext ctx, Object evt); }
ByteToMessageDecoder extends ChannelInboundHandlerAdapter { protected ByteBuf internalBuffer() { if (cumulation != null) { return cumulation; } else { return Unpooled.EMPTY_BUFFER; } } protected  ByteToMessageDecoder(); void setSingleDecode(boolean singleDecode); boolean isSingleDecode(); void setCumulator(Cumulator cumulator); void setDiscardAfterReads(int discardAfterReads); @Override final void handlerRemoved(ChannelHandlerContext ctx); static void main(String[] args); @Override void channelRead(ChannelHandlerContext ctx, Object msg); @Override void channelReadComplete(ChannelHandlerContext ctx); @Override void channelInactive(ChannelHandlerContext ctx); @Override void userEventTriggered(ChannelHandlerContext ctx, Object evt); static final Cumulator MERGE_CUMULATOR; static final Cumulator COMPOSITE_CUMULATOR; }