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:
parent
74495fd27f
commit
0b1c82b254
@ -121,7 +121,7 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
|||||||
composite = (CompositeByteBuf) cumulation;
|
composite = (CompositeByteBuf) cumulation;
|
||||||
} else {
|
} else {
|
||||||
int readable = cumulation.readableBytes();
|
int readable = cumulation.readableBytes();
|
||||||
composite = alloc.compositeBuffer();
|
composite = alloc.compositeBuffer(Integer.MAX_VALUE);
|
||||||
composite.addComponent(cumulation).writerIndex(readable);
|
composite.addComponent(cumulation).writerIndex(readable);
|
||||||
}
|
}
|
||||||
composite.addComponent(in).writerIndex(composite.writerIndex() + in.readableBytes());
|
composite.addComponent(in).writerIndex(composite.writerIndex() + in.readableBytes());
|
||||||
|
Loading…
Reference in New Issue
Block a user