From: DanielCV Date: Tue, 19 Jul 2022 13:39:05 +0000 (+0530) Subject: Allow NetconfChunkAggregator's maximum size to be adjusted X-Git-Tag: v4.0.1~6 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=netconf.git;a=commitdiff_plain;h=b48e597dad44046da6af9ada1b22df0b51aa3a9a Allow NetconfChunkAggregator's maximum size to be adjusted There are devices which send out arbitrarily-large chunks, requiring a potentially large buffer to hold the incoming message. This patch allows each instance to have a the chunk size specified as well as control over the default size via a system property. JIRA: NETCONF-888 Change-Id: Iec041a4ba9c8886cceb44fa86d07320bb5ae942b Signed-off-by: DanielCV Signed-off-by: Robert Varga --- diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java index 3949db62d2..6ee1c8b57c 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java @@ -10,6 +10,7 @@ package org.opendaylight.netconf.nettyutil; import static com.google.common.base.Preconditions.checkState; import static java.util.Objects.requireNonNull; +import com.google.common.annotations.Beta; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -20,6 +21,7 @@ import io.netty.util.Timer; import io.netty.util.concurrent.Promise; import java.util.Optional; import java.util.concurrent.TimeUnit; +import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.lock.qual.GuardedBy; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.netconf.api.NetconfDocumentedException; @@ -50,6 +52,27 @@ public abstract class AbstractNetconfSessionNegotiator 0, "Negative maximum chunk size %s", maxChunkSize); + } + private static void checkNewLine(final byte byteToCheck, final String errorMessage) { if (byteToCheck != '\n') { LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM, byteToCheck, (byte)'\n'); @@ -59,7 +82,7 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder { private void checkChunkSize() { if (chunkSize > maxChunkSize) { LOG.debug("Parsed chunk size {}, maximum allowed is {}", chunkSize, maxChunkSize); - throw new IllegalStateException("Maximum chunk size exceeded"); + throw new IllegalStateException("Chunk size " + chunkSize + " exceeds maximum " + maxChunkSize); } }