From be7b24246e98ddd043311cad98aa37df481f23e8 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <daniel.gerhardt@mni.thm.de>
Date: Tue, 12 Mar 2013 14:13:55 +0100
Subject: [PATCH] Catch all exceptions on Socket.IO shutdown. A thrown
 exception would prevent the Socket.IO server from stopping and cause a
 redeployment to fail because of the still running server.

---
 .../de/thm/arsnova/socket/ARSnovaSocketIOServer.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
index 224faa86b..d1e55601b 100644
--- a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+++ b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
@@ -136,9 +136,14 @@ public class ARSnovaSocketIOServer {
 	}
 
 	public void stopServer() throws Exception {
-		logger.debug("In stopServer method of class: {}", getClass().getName());
-		for (SocketIOClient client : server.getAllClients()) {
-			client.disconnect();
+		logger.trace("In stopServer method of class: {}", getClass().getName());
+		try {
+			for (SocketIOClient client : server.getAllClients()) {
+				client.disconnect();
+			}
+		} catch (Exception e) {
+			/* If exceptions are not caught they could prevent the Socket.IO server from shutting down. */
+			logger.error("Exception caught on Socket.IO shutdown: {}", e.getStackTrace());
 		}
 		server.stop();
 
-- 
GitLab