From 77cedd1e445f7efc325c185aca8c41fe3b6d606b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 31 May 2022 20:59:29 +0200 Subject: [PATCH] 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 --- .../netconf/nettyutil/NetconfSessionPromise.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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()); } -- 2.36.6