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 35695f75102870a00c31f631ca6f26a3b7e5320f..2db3c9d4f1d538893da1b9de420c696ef555e242 100644 (file)
@@ -45,6 +45,7 @@ public class NetconfOperationServiceFactoryImpl implements NetconfOperationServi
                 try {
                     Thread.sleep(ATTEMPT_TIMEOUT_MS);
                 } catch (InterruptedException e1) {
                 try {
                     Thread.sleep(ATTEMPT_TIMEOUT_MS);
                 } catch (InterruptedException e1) {
+                    Thread.currentThread().interrupt();
                     throw new RuntimeException(e1);
                 }
                 continue;
                     throw new RuntimeException(e1);
                 }
                 continue;
index 656091115c8907aa5de61394e1a6a6f9da516317..3c901c3f59e1f45194a5d17cc7979f48932a623b 100644 (file)
@@ -78,7 +78,10 @@ public class ConfigPersisterActivator implements BundleActivator {
                             ignoredMissingCapabilityRegex);
                     jmxNotificationHandler.init();
                 } catch (InterruptedException e) {
                             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 8b8c886a1c0328b558a4992c7d67b6b99b71800c..67d95bb90f74ac2098c4677e5cdab002cb1624da 100644 (file)
@@ -110,6 +110,7 @@ public class NetconfClient implements Closeable {
         try {
             return sessionListener.getLastMessage(attempts, attemptMsDelay);
         } catch (InterruptedException e) {
         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);
             throw new RuntimeException(this + " Cannot read message from " + address, e);
         } catch (IllegalStateException e) {
             throw new IllegalStateException(this + " Cannot read message from " + address, e);
index 32de75ca3969a039bbeb0046fc4c2a7b55d3462d..6df19155110e098ea093b370f2473e8ed9135704 100644 (file)
@@ -108,6 +108,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
                                         netconf_ssh_input.join();
                                     }
                                 } catch (InterruptedException e) {
                                         netconf_ssh_input.join();
                                     }
                                 } catch (InterruptedException e) {
+                                    Thread.currentThread().interrupt();
                                    logger.error("netconf_ssh_input join error ",e);
                                 }
 
                                    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) {
                                         netconf_ssh_output.join();
                                     }
                                 } catch (InterruptedException e) {
+                                    Thread.currentThread().interrupt();
                                     logger.error("netconf_ssh_output join error ",e);
                                 }
 
                                     logger.error("netconf_ssh_output join error ",e);
                                 }
 
index 07c81b0ccb7127aad1a5ffc14a3e6d6412dd1446..4b9bfbf5f826ee13c34127d902c2ad583d5f8eb4 100644 (file)
@@ -57,6 +57,7 @@ public class ChannelInputStream extends InputStream implements ChannelInboundHan
                 try {
                     lock.wait();
                 } catch (InterruptedException e) {
                 try {
                     lock.wait();
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                     throw new RuntimeException(e);
                 }
             }
                     throw new RuntimeException(e);
                 }
             }