Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthorityRuleManager并发场景下动态更新黑白名单,可能会导致黑白名单验证失效 #2655

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public final class AuthorityRuleManager {

private static Map<String, Set<AuthorityRule>> authorityRules = new ConcurrentHashMap<>();
private static volatile Map<String, Set<AuthorityRule>> authorityRules = new ConcurrentHashMap<>();

private static final RulePropertyListener LISTENER = new RulePropertyListener();
private static SentinelProperty<List<AuthorityRule>> currentProperty = new DynamicSentinelProperty<>();
Expand Down Expand Up @@ -93,12 +93,8 @@ private static class RulePropertyListener implements PropertyListener<List<Autho

@Override
public void configUpdate(List<AuthorityRule> conf) {
Map<String, Set<AuthorityRule>> rules = loadAuthorityConf(conf);

authorityRules.clear();
if (rules != null) {
authorityRules.putAll(rules);
}
authorityRules = loadAuthorityConf(conf);

RecordLog.info("[AuthorityRuleManager] Authority rules received: {}", authorityRules);
}

Expand Down Expand Up @@ -137,12 +133,8 @@ private Map<String, Set<AuthorityRule>> loadAuthorityConf(List<AuthorityRule> li

@Override
public void configLoad(List<AuthorityRule> value) {
Map<String, Set<AuthorityRule>> rules = loadAuthorityConf(value);
authorityRules = loadAuthorityConf(value);

authorityRules.clear();
if (rules != null) {
authorityRules.putAll(rules);
}
RecordLog.info("[AuthorityRuleManager] Load authority rules: {}", authorityRules);
}
}
Expand Down