Hide NAME_OF_EXCEPTION_HANDLER
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / AbstractNetconfSessionNegotiator.java
index 9a9225b247f0c53ead8c1000e38d06561e7ccb1d..bbe563b5b19e8ea5b5fed2cf92ac81c74df61e0c 100644 (file)
@@ -11,14 +11,12 @@ import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.Timeout;
 import io.netty.util.Timer;
-import io.netty.util.concurrent.GenericFutureListener;
 import io.netty.util.concurrent.Promise;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -51,8 +49,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSessionNegotiator.class);
-
-    public static final String NAME_OF_EXCEPTION_HANDLER = "lastExceptionHandler";
+    private static final String NAME_OF_EXCEPTION_HANDLER = "lastExceptionHandler";
 
     protected final P sessionPreferences;
     protected final Channel channel;
@@ -104,7 +101,7 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         return Optional.ofNullable(channel.pipeline().get(SslHandler.class));
     }
 
-    public P getSessionPreferences() {
+    public final P getSessionPreferences() {
         return sessionPreferences;
     }
 
@@ -134,11 +131,11 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
                     connectionTimeoutMillis);
                 changeState(State.FAILED);
 
-                channel.close().addListener((GenericFutureListener<ChannelFuture>) future -> {
+                channel.close().addListener(future -> {
                     if (future.isSuccess()) {
-                        LOG.debug("Channel {} closed: success", future.channel());
+                        LOG.debug("Channel {} closed: success", channel);
                     } else {
-                        LOG.warn("Channel {} closed: fail", future.channel());
+                        LOG.warn("Channel {} closed: fail", channel);
                     }
                 });
             }
@@ -165,6 +162,9 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         return getSession(sessionListener, channel, netconfMessage);
     }
 
+    protected abstract S getSession(L sessionListener, Channel channel, NetconfHelloMessage message)
+        throws NetconfDocumentedException;
+
     /**
      * Insert chunk framing handlers into the pipeline.
      */
@@ -218,10 +218,6 @@ public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionP
         return channel.pipeline().replace(handlerKey, handlerKey, decoder);
     }
 
-    @SuppressWarnings("checkstyle:hiddenField")
-    protected abstract S getSession(L sessionListener, Channel channel, NetconfHelloMessage message)
-            throws NetconfDocumentedException;
-
     private synchronized void changeState(final State newState) {
         LOG.debug("Changing state from : {} to : {} for channel: {}", state, newState, channel);
         checkState(isStateChangePermitted(state, newState),