From cd02fad290f71ae7342d798f191a557fbc59b921 Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Mon, 28 Jan 2019 09:49:25 +0800 Subject: [PATCH] Fix NPE bug when creating connection group in ConnectionManager - The NPE will occur when multiple threads are trying to create the connection group for the same namespace Signed-off-by: Eric Zhao --- .../sentinel/cluster/server/connection/ConnectionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ConnectionManager.java b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ConnectionManager.java index 5bbbaeaa..6b6be604 100644 --- a/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ConnectionManager.java +++ b/sentinel-cluster/sentinel-cluster-server-default/src/main/java/com/alibaba/csp/sentinel/cluster/server/connection/ConnectionManager.java @@ -55,7 +55,7 @@ public final class ConnectionManager { ConnectionGroup group = CONN_MAP.get(namespace); if (group == null) { synchronized (CREATE_LOCK) { - if (CONN_MAP.get(namespace) == null) { + if ((group = CONN_MAP.get(namespace)) == null) { group = new ConnectionGroup(namespace); CONN_MAP.put(namespace, group); }