Make netconf client throw checked Interrupted exception instead of unchecked 02/2002/2
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 18 Oct 2013 08:18:37 +0000 (10:18 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 20 Oct 2013 21:00:27 +0000 (21:00 +0000)
Change-Id: Id49cc22fc463c754aca98fb03e53afe38b6c9ac4
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java

index b5a06ca0ab47f5ff13b0f016152ac081d26f0e6f..b8372b618c2d2b20bfaf1e1e8117b9d065b7cb4f 100644 (file)
@@ -42,13 +42,13 @@ public class NetconfClient implements Closeable {
 
     // TODO test reconnecting constructor
     public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectionAttempts,
-            int attemptMsTimeout) {
+            int attemptMsTimeout) throws InterruptedException {
         this(clientLabelForLogging, address, getReconnectStrategy(connectionAttempts, attemptMsTimeout), Optional
                 .<SSLContext> absent());
     }
 
     private NetconfClient(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strat,
-            Optional<SSLContext> maybeSSLContext) {
+            Optional<SSLContext> maybeSSLContext) throws InterruptedException {
         this.label = clientLabelForLogging;
         dispatch = new NetconfClientDispatcher(maybeSSLContext);
 
@@ -59,10 +59,10 @@ public class NetconfClient implements Closeable {
         this.sessionId = clientSession.getSessionId();
     }
 
-    private NetconfClientSession get(Future<NetconfClientSession> clientFuture) {
+    private NetconfClientSession get(Future<NetconfClientSession> clientFuture) throws InterruptedException {
         try {
             return clientFuture.get();
-        } catch (InterruptedException | CancellationException e) {
+        } catch (CancellationException e) {
             throw new RuntimeException("Netconf client interrupted", e);
         } catch (ExecutionException e) {
             throw new IllegalStateException("Unable to create netconf client", e);
@@ -70,23 +70,25 @@ public class NetconfClient implements Closeable {
     }
 
     public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs,
-            Optional<SSLContext> maybeSSLContext) {
+            Optional<SSLContext> maybeSSLContext) throws InterruptedException {
         this(clientLabelForLogging, address,
                 new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, connectTimeoutMs), maybeSSLContext);
     }
 
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs) {
+    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs)
+            throws InterruptedException {
         this(clientLabelForLogging, address,
                 new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, connectTimeoutMs), Optional
                         .<SSLContext> absent());
     }
 
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address) {
+    public NetconfClient(String clientLabelForLogging, InetSocketAddress address) throws InterruptedException {
         this(clientLabelForLogging, address, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
                 DEFAULT_CONNECT_TIMEOUT), Optional.<SSLContext> absent());
     }
 
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, Optional<SSLContext> maybeSSLContext) {
+    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, Optional<SSLContext> maybeSSLContext)
+            throws InterruptedException {
         this(clientLabelForLogging, address, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
                 DEFAULT_CONNECT_TIMEOUT), maybeSSLContext);
     }