diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java index 22b698dd46..8ce0adf447 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleManager.java @@ -39,7 +39,7 @@ */ public final class AuthorityRuleManager { - private static Map> authorityRules = new ConcurrentHashMap<>(); + private static volatile Map> authorityRules = new ConcurrentHashMap<>(); private static final RulePropertyListener LISTENER = new RulePropertyListener(); private static SentinelProperty> currentProperty = new DynamicSentinelProperty<>(); @@ -93,12 +93,8 @@ private static class RulePropertyListener implements PropertyListener conf) { - Map> rules = loadAuthorityConf(conf); - - authorityRules.clear(); - if (rules != null) { - authorityRules.putAll(rules); - } + authorityRules = loadAuthorityConf(conf); + RecordLog.info("[AuthorityRuleManager] Authority rules received: {}", authorityRules); } @@ -137,12 +133,8 @@ private Map> loadAuthorityConf(List li @Override public void configLoad(List value) { - Map> rules = loadAuthorityConf(value); + authorityRules = loadAuthorityConf(value); - authorityRules.clear(); - if (rules != null) { - authorityRules.putAll(rules); - } RecordLog.info("[AuthorityRuleManager] Load authority rules: {}", authorityRules); } }