X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fnettyutil%2FNetconfSessionPromise.java;h=4a8fb7f88c897b885eff082010e7b55898a165a6;hb=29e06cbd92b039d501a004cabcf0eb19f63c427a;hp=178be8bfe1f3ef13ec748eb6c2c39aad2af929f7;hpb=77cedd1e445f7efc325c185aca8c41fe3b6d606b;p=netconf.git diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java index 178be8bfe1..4a8fb7f88c 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionPromise.java @@ -54,18 +54,21 @@ final class NetconfSessionPromise extends DefaultPromi LOG.debug("Promise {} attempting connect for {}ms", this, timeout); + final ChannelFuture connectFuture; try { if (address.isUnresolved()) { address = new InetSocketAddress(address.getHostName(), address.getPort()); } - final ChannelFuture connectFuture = bootstrap.connect(address); - pending = connectFuture; - // Add listener that attempts reconnect by invoking this method again. - connectFuture.addListener((ChannelFutureListener) this::channelConnectComplete); + connectFuture = bootstrap.connect(address); } catch (final Exception e) { LOG.info("Failed to connect to {}", address, e); setFailure(e); + return; } + + pending = connectFuture; + // Add listener that attempts reconnect by invoking this method again. + connectFuture.addListener((ChannelFutureListener) this::channelConnectComplete); } @Override