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 74495fd27f
commit 0b1c82b254

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());