From: Robert Varga Date: Tue, 31 May 2022 18:59:29 +0000 (+0200) Subject: Split out strategy decision error handling X-Git-Tag: v4.0.0~7 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F101381%2F7;p=netconf.git Split out strategy decision error handling When the strategy determines that a connection attempt should not be made it will throw an exception. Peel this case out of the rest of connection handling and add a dedicated message. Change-Id: I9dd897f487421ba096240ebc9e3d999a7a5d7489 Signed-off-by: Robert Varga --- 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 d7722fe3bc..178be8bfe1 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 @@ -43,11 +43,18 @@ final class NetconfSessionPromise extends DefaultPromi @SuppressWarnings("checkstyle:illegalCatch") synchronized void connect() { + final int timeout; try { - final int timeout = strategy.getConnectTimeout(); + timeout = strategy.getConnectTimeout(); + } catch (Exception e) { + LOG.info("Connection to {} aborted due to strategy decision", address, e); + setFailure(e); + return; + } - LOG.debug("Promise {} attempting connect for {}ms", this, timeout); + LOG.debug("Promise {} attempting connect for {}ms", this, timeout); + try { if (address.isUnresolved()) { address = new InetSocketAddress(address.getHostName(), address.getPort()); }