diff --git a/kernel-d-socket/socket-business-websocket/src/main/java/cn/stylefeng/roses/kernel/socket/business/websocket/session/SessionCenter.java b/kernel-d-socket/socket-business-websocket/src/main/java/cn/stylefeng/roses/kernel/socket/business/websocket/session/SessionCenter.java index 872a6f4ee..53760fbc9 100644 --- a/kernel-d-socket/socket-business-websocket/src/main/java/cn/stylefeng/roses/kernel/socket/business/websocket/session/SessionCenter.java +++ b/kernel-d-socket/socket-business-websocket/src/main/java/cn/stylefeng/roses/kernel/socket/business/websocket/session/SessionCenter.java @@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap; public class SessionCenter { /** - * 所有会话维护 + * 所有用户会话维护 */ private static ConcurrentMap>> socketSessionMap = new ConcurrentHashMap<>(); @@ -87,7 +87,7 @@ public class SessionCenter { public static void addSocketSession(SocketSession socketSession) { List> socketSessions = socketSessionMap.get(socketSession.getUserId()); if (ObjectUtil.isEmpty(socketSessions)) { - socketSessions = new ArrayList<>(); + socketSessions = Collections.synchronizedList(new ArrayList<>()); socketSessionMap.put(socketSession.getUserId(), socketSessions); } socketSessions.add(socketSession);