Ensure read components can be discarded when COMPOSITE_CUMULATOR is used.

Motivation:

ByteToMessageDecoder must ensure that read components of the CompositeByteBuf can be discard by default when discardSomeReadBytes() is called. This may not be the case before as because of the default maxNumComponents that will cause consolidation.

Modifications:

Ensure we not do any consolidation to actually be abel to discard read components

Result:

Less memory usage and allocations.
This commit is contained in:
Norman Maurer 2016-02-15 22:14:56 -08:00
parent 4f460a1680
commit c64fe509dd

View File

@ -121,7 +121,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
composite = (CompositeByteBuf) cumulation;
} else {
int readable = cumulation.readableBytes();
composite = alloc.compositeBuffer();
composite = alloc.compositeBuffer(Integer.MAX_VALUE);
composite.addComponent(cumulation).writerIndex(readable);
}
composite.addComponent(in).writerIndex(composite.writerIndex() + in.readableBytes());