diff --git a/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/GenericWebSocketClient.java b/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/GenericWebSocketClient.java index 61f0b2dbe30..3f065e8cebf 100644 --- a/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/GenericWebSocketClient.java +++ b/lib/websocket-client/src/main/java/org/triplea/http/client/web/socket/GenericWebSocketClient.java @@ -6,6 +6,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -44,7 +45,8 @@ public class GenericWebSocketClient implements WebSocket, WebSocketConnectionLis private final Function webSocketConnectionFactory; private WebSocketConnection webSocketConnection; - private final Set> listeners = new HashSet<>(); + private final Set> listeners = + Collections.synchronizedSet(new HashSet<>()); @Builder private static class MessageListener { @@ -147,6 +149,7 @@ public void connectionTerminated(final String reason) { @Override public void handleError(final Throwable exception) { + log.error("Web Socket error", exception); errorHandler.accept(exception.getMessage()); } }