From 0b1c82b25444bb244a33008d23863d5a0e82a323 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 15 Feb 2016 22:14:56 -0800 Subject: [PATCH] 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. --- .../main/java/io/netty/handler/codec/ByteToMessageDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java index 98620292b2..d61d869282 100644 --- a/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java +++ b/codec/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java @@ -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());