From 7feaf709fcb0db4f56647b97d3c96d4204c7b657 Mon Sep 17 00:00:00 2001 From: Carpenter Lee Date: Mon, 25 Mar 2019 09:22:38 +0800 Subject: [PATCH] Fix deadlock bug in Env static initialization (#610) Signed-off-by: Carpenter Lee --- .../src/main/java/com/alibaba/csp/sentinel/Constants.java | 2 +- .../src/main/java/com/alibaba/csp/sentinel/Env.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Constants.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Constants.java index 2c5ade24..ba6e12d2 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Constants.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Constants.java @@ -41,7 +41,7 @@ public final class Constants { public final static String TOTAL_IN_RESOURCE_NAME = "__total_inbound_traffic__"; public final static DefaultNode ROOT = new EntranceNode(new StringResourceWrapper(ROOT_ID, EntryType.IN), - Env.nodeBuilder.buildClusterNode()); + new ClusterNode()); /** * Statistics for {@link SystemRule} checking. diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Env.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Env.java index 31a69291..20538f3b 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Env.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/Env.java @@ -20,6 +20,13 @@ import com.alibaba.csp.sentinel.node.DefaultNodeBuilder; import com.alibaba.csp.sentinel.node.NodeBuilder; /** + * Sentinel Env. This class will trigger all initialization for Sentinel. + * + *

+ * NOTE: to prevent deadlocks, other classes' static code block or static field should + * NEVER refer to this class. + *

+ * * @author jialiang.linjl */ public class Env {