From 89962f0326128bdae2bf1dfef0a8ddc01609b184 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 2 Jun 2022 11:51:59 +0200 Subject: [PATCH] ServerChannelInitializer should be final This is a simple implementation class, make sure it is final to keep its interactions well-defined. Change-Id: I7e276e85cf7c08e470657c46b5c2d394bee65a8d Signed-off-by: Robert Varga --- .../impl/ServerChannelInitializer.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/ServerChannelInitializer.java b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/ServerChannelInitializer.java index df39613f8a..d75c665d8b 100644 --- a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/ServerChannelInitializer.java +++ b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/ServerChannelInitializer.java @@ -7,32 +7,31 @@ */ package org.opendaylight.netconf.impl; +import static java.util.Objects.requireNonNull; + import io.netty.channel.Channel; import io.netty.util.concurrent.Promise; import org.opendaylight.netconf.impl.util.DeserializerExceptionHandler; import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer; -public class ServerChannelInitializer extends AbstractChannelInitializer { - - public static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler"; +public final class ServerChannelInitializer extends AbstractChannelInitializer { + private static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler"; private final NetconfServerSessionNegotiatorFactory negotiatorFactory; - - public ServerChannelInitializer(NetconfServerSessionNegotiatorFactory negotiatorFactory) { - this.negotiatorFactory = negotiatorFactory; - + public ServerChannelInitializer(final NetconfServerSessionNegotiatorFactory negotiatorFactory) { + this.negotiatorFactory = requireNonNull(negotiatorFactory); } @Override - protected void initializeMessageDecoder(Channel ch) { + protected void initializeMessageDecoder(final Channel ch) { super.initializeMessageDecoder(ch); ch.pipeline().addLast(DESERIALIZER_EX_HANDLER_KEY, new DeserializerExceptionHandler()); } @Override - protected void initializeSessionNegotiator(Channel ch, Promise promise) { - ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR, - negotiatorFactory.getSessionNegotiator(null, ch, promise)); + protected void initializeSessionNegotiator(final Channel ch, final Promise promise) { + ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, NETCONF_SESSION_NEGOTIATOR, + negotiatorFactory.getSessionNegotiator(null, ch, promise)); } } -- 2.36.6