Merge "BUG-509: migrate to TreeNodes"
[controller.git] / opendaylight / netconf / netconf-ssh / src / main / java / org / opendaylight / controller / netconf / ssh / NetconfSSHServer.java
index ff950e95e9700289bf9dda3bed79642f1fba096e..c6974d4982db051f1cb6a66d3f67394ee2d57817 100644 (file)
@@ -27,7 +27,7 @@ public final class NetconfSSHServer implements Runnable {
     private static final AtomicLong sesssionId = new AtomicLong();
     private final InetSocketAddress clientAddress;
     private final AuthProvider authProvider;
-    private boolean up = false;
+    private volatile boolean up = false;
 
     private NetconfSSHServer(int serverPort,InetSocketAddress clientAddress, AuthProvider authProvider) throws IllegalStateException, IOException {
 
@@ -68,9 +68,17 @@ public final class NetconfSSHServer implements Runnable {
         while (up) {
             logger.trace("Starting new socket thread.");
             try {
-               SocketThread.start(ss.accept(), clientAddress, sesssionId.incrementAndGet(), authProvider);
-            } catch (IOException e) {
-                logger.error("Exception occurred during socket thread initialization {}", e);
+                SocketThread.start(ss.accept(), clientAddress, sesssionId.incrementAndGet(), authProvider);
+            }
+            catch (IOException e) {
+                if( up ) {
+                    logger.error("Exception occurred during socket thread initialization", e);
+                }
+                else {
+                    // We're shutting down so an exception is expected as the socket's been closed.
+                    // Log to debug.
+                    logger.debug("Shutting down - got expected exception: " + e);
+                }
             }
         }
     }