This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 df787165095 Remove useless codes on AuthenticatorFactory (#30078)
df787165095 is described below

commit df7871650952c08053537dffbfd4f5886d2ba47f
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 8 21:48:12 2024 +0800

    Remove useless codes on AuthenticatorFactory (#30078)
---
 .../shardingsphere/authentication/AuthenticatorFactory.java    | 10 +++-------
 .../apache/shardingsphere/authority/rule/AuthorityRule.java    |  3 +--
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authentication/AuthenticatorFactory.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authentication/AuthenticatorFactory.java
index 552806d2583..802d556f45c 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authentication/AuthenticatorFactory.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authentication/AuthenticatorFactory.java
@@ -45,16 +45,12 @@ public final class AuthenticatorFactory<E extends Enum<E> & 
AuthenticatorType> {
     @SneakyThrows(ReflectiveOperationException.class)
     public Authenticator newInstance(final ShardingSphereUser user) {
         E authenticatorType = 
getAuthenticatorType(rule.getAuthenticatorType(user));
-        try {
-            return 
authenticatorType.getAuthenticatorClass().getConstructor().newInstance();
-        } catch (final NoSuchMethodException ignored) {
-            return 
authenticatorType.getAuthenticatorClass().getConstructor(AuthorityRule.class).newInstance(rule);
-        }
+        return 
authenticatorType.getAuthenticatorClass().getConstructor().newInstance();
     }
     
-    private E getAuthenticatorType(final String authenticationMethod) {
+    private E getAuthenticatorType(final String authenticationMethodName) {
         try {
-            return E.valueOf(authenticatorTypeClass, 
authenticationMethod.toUpperCase());
+            return E.valueOf(authenticatorTypeClass, 
authenticationMethodName.toUpperCase());
         } catch (final IllegalArgumentException ignored) {
             return 
Arrays.stream(authenticatorTypeClass.getEnumConstants()).filter(AuthenticatorType::isDefault).findAny().orElseThrow(IllegalArgumentException::new);
         }
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 318669f61e6..3da1c4e7bcd 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
@@ -41,8 +41,7 @@ public final class AuthorityRule implements GlobalRule {
     
     public AuthorityRule(final AuthorityRuleConfiguration ruleConfig) {
         configuration = ruleConfig;
-        PrivilegeProvider provider = 
TypedSPILoader.getService(PrivilegeProvider.class, 
ruleConfig.getPrivilegeProvider().getType(), 
ruleConfig.getPrivilegeProvider().getProps());
-        privileges = provider.build(ruleConfig);
+        privileges = TypedSPILoader.getService(PrivilegeProvider.class, 
ruleConfig.getPrivilegeProvider().getType(), 
ruleConfig.getPrivilegeProvider().getProps()).build(ruleConfig);
     }
     
     /**

Reply via email to