From 01e65a01c79ee35c9b621e592b59b7b073472c9d Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 8 Feb 2013 17:41:43 +0900 Subject: [PATCH] Make ReplayingDecoder.newInboundBuffer/discardInboundReadByte() final for safety --- .../netty/handler/codec/ReplayingDecoder.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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();