Make ReplayingDecoder.newInboundBuffer/discardInboundReadByte() final for safety

This commit is contained in:
Trustin Lee 2013-02-08 17:41:43 +09:00
parent 82c46180c9
commit 01e65a01c7

View File

@ -342,22 +342,29 @@ public abstract class ReplayingDecoder<S> extends ByteToMessageDecoder {
} }
@Override @Override
public ByteBuf newInboundBuffer( public final ByteBuf newInboundBuffer(ChannelHandlerContext ctx) throws Exception {
ChannelHandlerContext ctx) throws Exception { cumulation = newInboundBuffer0(ctx);
cumulation = ctx.alloc().buffer();
replayable = new ReplayingDecoderBuffer(cumulation); replayable = new ReplayingDecoderBuffer(cumulation);
return cumulation; return cumulation;
} }
protected ByteBuf newInboundBuffer0(ChannelHandlerContext ctx) throws Exception {
return super.newInboundBuffer(ctx);
}
@Override @Override
public void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception { public final void discardInboundReadBytes(ChannelHandlerContext ctx) throws Exception {
ByteBuf in = ctx.inboundByteBuffer(); ByteBuf in = ctx.inboundByteBuffer();
final int oldReaderIndex = in.readerIndex(); final int oldReaderIndex = in.readerIndex();
super.discardInboundReadBytes(ctx); discardInboundReadBytes0(ctx);
final int newReaderIndex = in.readerIndex(); final int newReaderIndex = in.readerIndex();
checkpoint -= oldReaderIndex - newReaderIndex; checkpoint -= oldReaderIndex - newReaderIndex;
} }
protected void discardInboundReadBytes0(ChannelHandlerContext ctx) throws Exception {
super.discardInboundReadBytes(ctx);
}
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
replayable.terminate(); replayable.terminate();