Always set interrupted flag when catching InterruptedException. 11/4111/1
authorTomas Olvecky <tolvecky@cisco.com>
Thu, 9 Jan 2014 13:08:08 +0000 (14:08 +0100)
committerTomas Olvecky <tolvecky@cisco.com>
Thu, 9 Jan 2014 13:08:35 +0000 (14:08 +0100)
Fixed catching InterruptedException in config-subsystem and netconf.
In netconf persister propagate interrupted exception as it indicates
that netconf connection was not established and thus config pushing
does not work.

Change-Id: I7934bddd2b7c6591d1a4557a60df39a6de15dc72
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/handler/ssh/virtualsocket/ChannelInputStream.java

index 35695f7..2db3c9d 100644 (file)
@@ -45,6 +45,7 @@ public class NetconfOperationServiceFactoryImpl implements NetconfOperationServi
                 try {
                     Thread.sleep(ATTEMPT_TIMEOUT_MS);
                 } catch (InterruptedException e1) {
+                    Thread.currentThread().interrupt();
                     throw new RuntimeException(e1);
                 }
                 continue;
index 6560911..3c901c3 100644 (file)
@@ -78,7 +78,10 @@ public class ConfigPersisterActivator implements BundleActivator {
                             ignoredMissingCapabilityRegex);
                     jmxNotificationHandler.init();
                 } catch (InterruptedException e) {
-                    logger.info("Interrupted while waiting for netconf connection");
+                    Thread.currentThread().interrupt();
+                    logger.error("Interrupted while waiting for netconf connection");
+                    // uncaught exception handler will deal with this failure
+                    throw new RuntimeException("Interrupted while waiting for netconf connection", e);
                 }
             }
         };
index 8b8c886..67d95bb 100644 (file)
@@ -110,6 +110,7 @@ public class NetconfClient implements Closeable {
         try {
             return sessionListener.getLastMessage(attempts, attemptMsDelay);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new RuntimeException(this + " Cannot read message from " + address, e);
         } catch (IllegalStateException e) {
             throw new IllegalStateException(this + " Cannot read message from " + address, e);
index 32de75c..6df1915 100644 (file)
@@ -108,6 +108,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
                                         netconf_ssh_input.join();
                                     }
                                 } catch (InterruptedException e) {
+                                    Thread.currentThread().interrupt();
                                    logger.error("netconf_ssh_input join error ",e);
                                 }
 
@@ -116,6 +117,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
                                         netconf_ssh_output.join();
                                     }
                                 } catch (InterruptedException e) {
+                                    Thread.currentThread().interrupt();
                                     logger.error("netconf_ssh_output join error ",e);
                                 }
 
index 07c81b0..4b9bfbf 100644 (file)
@@ -57,6 +57,7 @@ public class ChannelInputStream extends InputStream implements ChannelInboundHan
                 try {
                     lock.wait();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     throw new RuntimeException(e);
                 }
             }