Bug 716: Errors on controller shutdown
authortpantelis <tpanteli@brocade.com>
Tue, 22 Apr 2014 16:05:23 +0000 (12:05 -0400)
committertpantelis <tpanteli@brocade.com>
Sun, 11 May 2014 03:01:56 +0000 (23:01 -0400)
    Fixed miscellaneous errors on shutdown:
        -  FlowProvider, GroupProvider and MeterProvider: all throw an
           UnsupportedOperationEx from their close methods with a TODO message.
           Implemented close to close the commitHandlerRegistration.

        - NetconfSSHServer: logs a socket closed exception due to closing the socket
          on shutdown. We can ignore this and not log the error (if 'up' is false).

        - RestconfProvider: NPE in stop method calling session.close.
          The 'session' member is never initialized or otherwise used so removed it.

        - RuntimeMappingModule and SchemaServiceImplSingletonModule:
          IllegalStateException from bundleContext.ungetService() call because the
          bundle has already been shutdown. Ignore ex as this can occur
          normally.

Need someone to commit this!

Change-Id: I31d9d6d66418dda7f5b73c2ad12bb251f3689643
Signed-off-by: tpantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/RestconfProvider.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/NetconfSSHServer.java

index 1870bdf0bf37daf6e5e0acaee273b90ce3c749a5..2abd4b6a3ab5b9a08c56e782257a262db80fbfe2 100644 (file)
@@ -34,7 +34,6 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack
     private ListenerRegistration<SchemaServiceListener> listenerRegistration;
     private ServiceTracker<Broker, Broker> brokerServiceTrancker;
     private BundleContext bundleContext;
-    private ProviderSession session;
     private Thread webSocketServerThread;
 
     @Override
@@ -70,7 +69,6 @@ public class RestconfProvider implements BundleActivator, Provider, ServiceTrack
             }
         }
         webSocketServerThread.interrupt();
-        session.close();
         brokerServiceTrancker.close();
     }
 
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);
+                }
             }
         }
     }