- public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress,
+ public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
+ final SocketAddress localAddress,
final ChannelPromise channelPromise) throws Exception {
connectPromise = channelPromise;
ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch);
negotiationFutureListener = future -> {
if (future.isSuccess()) {
final ChannelPromise channelPromise) throws Exception {
connectPromise = channelPromise;
ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch);
negotiationFutureListener = future -> {
if (future.isSuccess()) {
//complete connection promise with netconf negotiation future
negotiationFuture.addListener(negotiationFutureListener);
} else {
//complete connection promise with netconf negotiation future
negotiationFuture.addListener(negotiationFutureListener);
} else {
- // If we have already succeeded and the session was dropped after, we need to fire inactive to notify reconnect logic
- if(connectPromise.isSuccess()) {
+ 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()) {
ctx.fireChannelInactive();
}
//If connection promise is not already set, it means negotiation failed
//we must set connection promise to failure
ctx.fireChannelInactive();
}
//If connection promise is not already set, it means negotiation failed
//we must set connection promise to failure