Remove a FindBugs suppression
[netconf.git] / netconf / netconf-client / src / main / java / org / opendaylight / netconf / client / TcpClientChannelInitializer.java
index 2cf0e1a5cd32e04aaabf297a695e786946f8723b..c241e17656736052b4cbe3bf48012c8891e02ea4 100644 (file)
@@ -43,13 +43,13 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
             @Override
             public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
                                 final SocketAddress localAddress,
-                                final ChannelPromise channelPromise) throws Exception {
+                                final ChannelPromise channelPromise) {
                 connectPromise = channelPromise;
                 ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch);
 
                 negotiationFutureListener = future -> {
                     if (future.isSuccess()) {
-                        connectPromise.setSuccess();
+                        channelPromise.setSuccess();
                     }
                 };
 
@@ -58,7 +58,7 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
                         //complete connection promise with netconf negotiation future
                         negotiationFuture.addListener(negotiationFutureListener);
                     } else {
-                        connectPromise.setFailure(future.cause());
+                        channelPromise.setFailure(future.cause());
                     }
                 });
                 ctx.connect(remoteAddress, localAddress, tcpConnectFuture);
@@ -66,6 +66,10 @@ class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClie
 
             @Override
             public void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
+                if (connectPromise == null) {
+                    return;
+                }
+
                 // If we have already succeeded and the session was dropped after, we need to fire inactive to notify
                 // reconnect logic
                 if (connectPromise.isSuccess()) {