Fixed a slew of shutdown exceptions that arose due to improper or out-of-order resource clean-up, e.g. listeners, timers, executors.
Change-Id: I37c351c4202b32e92c076d9d566b96d7ff8d313a
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
index c571f8f..958ad32 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiWebSocket.java
@@ -20,6 +20,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.eclipse.jetty.websocket.WebSocket;
import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.ServiceNotFoundException;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.ControllerNode;
import org.onosproject.ui.UiConnection;
@@ -100,11 +101,19 @@
@Override
public void onOpen(Connection connection) {
- log.info("GUI client connected");
this.connection = connection;
this.control = (FrameConnection) connection;
- createHandlers();
- sendInstanceData();
+ try {
+ createHandlers();
+ sendInstanceData();
+ log.info("GUI client connected");
+
+ } catch (ServiceNotFoundException e) {
+ log.warn("Unable to open GUI connection; services have been shut-down");
+ this.connection.close();
+ this.connection = null;
+ this.control = null;
+ }
}
@Override