From: Marian Dubai Date: Thu, 14 May 2015 16:55:03 +0000 (+0200) Subject: Bug 3197: Netconf client not reconnecting due address unresolved X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e45d1455db403b1177a131f7a06307b57008a782 Bug 3197: Netconf client not reconnecting due address unresolved Netconf client not reconnecting, when failed 1st time due address unresolved. InetSocketAddress remains in state unresolved, after connection failed first time due address unresolved. Now recreating InetSocketAddress by each reconnect, so address is checked by each reconnect attempt. Change-Id: I29ef130d7bf3f65023a611cee51245a6ae6f9a03 Signed-off-by: Marian Dubai --- diff --git a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java index b64c4828a4..494ccf8ec4 100644 --- a/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java +++ b/opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java @@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory; final class ProtocolSessionPromise> extends DefaultPromise { private static final Logger LOG = LoggerFactory.getLogger(ProtocolSessionPromise.class); private final ReconnectStrategy strategy; - private final InetSocketAddress address; + private InetSocketAddress address; private final Bootstrap b; @GuardedBy("this") @@ -50,6 +50,9 @@ final class ProtocolSessionPromise> extends Default LOG.debug("Promise {} attempting connect for {}ms", lock, timeout); + if(this.address.isUnresolved()) { + this.address = new InetSocketAddress(this.address.getHostName(), this.address.getPort()); + } this.b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, timeout); final ChannelFuture connectFuture = this.b.connect(this.address); // Add listener that attempts reconnect by invoking this method again.