diff --git a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java index 39e4614fbc..797266b924 100644 --- a/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ReplayingDecoder.java @@ -342,22 +342,29 @@ public abstract class ReplayingDecoder extends ByteToMessageDecoder { } @Override - public ByteBuf newInboundBuffer( - ChannelHandlerContext ctx) throws Exception { - cumulation = ctx.alloc().buffer(); + public final ByteBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception { + cumulation = newInboundBuffer0(ctx); replayable = new ReplayingDecoderBuffer(cumulation); return cumulation; } + protected ByteBuf newInboundBuffer0(ChannelHandlerContext ctx) throws Exception { + return super.newInboundBuffer(ctx); + } + @Override - public void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception { + public final void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception { ByteBuf in = ctx.inboundByteBuffer(); final int oldReaderIndex = in.readerIndex(); - super.discardInboundReadBytes(ctx); + discardInboundReadBytes0(ctx); final int newReaderIndex = in.readerIndex(); checkpoint -= oldReaderIndex - newReaderIndex; } + protected void discardInboundReadBytes0(ChannelHandlerContext ctx) throws Exception { + super.discardInboundReadBytes(ctx); + } + @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { replayable.terminate();