Skip to content

Commit 0b1c82b

Browse files
committed
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.
1 parent 74495fd commit 0b1c82b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public ByteBuf cumulate(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf in)
121121
composite = (CompositeByteBuf) cumulation;
122122
} else {
123123
int readable = cumulation.readableBytes();
124-
composite = alloc.compositeBuffer();
124+
composite = alloc.compositeBuffer(Integer.MAX_VALUE);
125125
composite.addComponent(cumulation).writerIndex(readable);
126126
}
127127
composite.addComponent(in).writerIndex(composite.writerIndex() + in.readableBytes());

0 commit comments

Comments
 (0)