You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zi...@apache.org on 2023/04/17 09:55:00 UTC
[shardingsphere] branch master updated: Remove useless method refresh from AuthorityRule. (#25196)
This is an automated email from the ASF dual-hosted git repository.
zichaowang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a74afc5c781 Remove useless method refresh from AuthorityRule. (#25196)
a74afc5c781 is described below
commit a74afc5c781fbb35ccf6bef9cfa4f110d19b680e
Author: Raigor <ra...@gmail.com>
AuthorDate: Mon Apr 17 17:54:52 2023 +0800
Remove useless method refresh from AuthorityRule. (#25196)
---
.../shardingsphere/authority/rule/AuthorityRule.java | 17 ++---------------
.../authority/rule/AuthorityRuleTest.java | 11 -----------
2 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
index ec74d02e11f..a4930d0c941 100644
--- a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
+++ b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
@@ -28,7 +28,6 @@ import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.identifier.scope.GlobalRule;
import org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPILoader;
-import java.util.Collection;
import java.util.Map;
import java.util.Optional;
@@ -40,13 +39,11 @@ public final class AuthorityRule implements GlobalRule {
@Getter
private final AuthorityRuleConfiguration configuration;
- private final AuthorityProvider provider;
-
- private volatile AuthorityRegistry authorityRegistry;
+ private final AuthorityRegistry authorityRegistry;
public AuthorityRule(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereDatabase> databases) {
configuration = ruleConfig;
- provider = TypedSPILoader.getService(AuthorityProvider.class, ruleConfig.getAuthorityProvider().getType(), ruleConfig.getAuthorityProvider().getProps());
+ AuthorityProvider provider = TypedSPILoader.getService(AuthorityProvider.class, ruleConfig.getAuthorityProvider().getType(), ruleConfig.getAuthorityProvider().getProps());
authorityRegistry = provider.buildAuthorityRegistry(databases, ruleConfig.getUsers());
}
@@ -82,16 +79,6 @@ public final class AuthorityRule implements GlobalRule {
return authorityRegistry.findPrivileges(grantee);
}
- /**
- * Refresh authority.
- *
- * @param databases databases
- * @param users users
- */
- public synchronized void refresh(final Map<String, ShardingSphereDatabase> databases, final Collection<ShardingSphereUser> users) {
- authorityRegistry = provider.buildAuthorityRegistry(databases, users);
- }
-
@Override
public String getType() {
return AuthorityRule.class.getSimpleName();
diff --git a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/rule/AuthorityRuleTest.java b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/rule/AuthorityRuleTest.java
index c448f56a5bf..582e9ac25c7 100644
--- a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/rule/AuthorityRuleTest.java
+++ b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/rule/AuthorityRuleTest.java
@@ -55,17 +55,6 @@ class AuthorityRuleTest {
assertTrue(createAuthorityRule().findPrivileges(new Grantee("admin", "localhost")).isPresent());
}
- @Test
- void assertRefresh() {
- Collection<ShardingSphereUser> users = new LinkedList<>();
- users.add(new ShardingSphereUser("root", "root", "localhost"));
- users.add(new ShardingSphereUser("admin", "123456", "localhost"));
- users.add(new ShardingSphereUser("sharding-sphere", "123456", "127.0.0.1"));
- AuthorityRule rule = createAuthorityRule();
- rule.refresh(Collections.emptyMap(), users);
- assertTrue(rule.findPrivileges(new Grantee("sharding-sphere", "localhost")).isPresent());
- }
-
private AuthorityRule createAuthorityRule() {
Collection<ShardingSphereUser> users = new LinkedList<>();
users.add(new ShardingSphereUser("root", "root", "localhost"));