From ea8e423e16c6603f748359281143173d223e761f Mon Sep 17 00:00:00 2001 From: rays <1615175118@qq.com> Date: Tue, 22 Jun 2021 16:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9list=E4=B8=BA=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=AE=89=E5=85=A8=E7=9A=84list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket/business/websocket/session/SessionCenter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);