Split out strategy decision error handling
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / NetconfSessionPromise.java
index d7722fe3bcad1f0a2c921ed97b41cb01e9e0d62a..178be8bfe1f3ef13ec748eb6c2c39aad2af929f7 100644 (file)
@@ -43,11 +43,18 @@ final class NetconfSessionPromise<S extends NetconfSession> 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());
             }