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

jianglongtao 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 9bf90468614 Refactor AuthorityChecker (#29599)
9bf90468614 is described below

commit 9bf90468614f70221068d012a22954d0b7f72b3e
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Dec 29 23:32:11 2023 +0800

    Refactor AuthorityChecker (#29599)
---
 .../apache/shardingsphere/authority/checker/AuthorityChecker.java   | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
index 0cffa38d9e0..3d8c1cac0d8 100644
--- 
a/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
+++ 
b/kernel/authority/core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
@@ -22,12 +22,11 @@ import 
org.apache.shardingsphere.authority.exception.UnauthorizedOperationExcept
 import org.apache.shardingsphere.authority.model.PrivilegeType;
 import org.apache.shardingsphere.authority.model.ShardingSpherePrivileges;
 import org.apache.shardingsphere.authority.rule.AuthorityRule;
+import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
-import java.util.Collections;
 import java.util.Optional;
 
 /**
@@ -64,7 +63,6 @@ public final class AuthorityChecker {
         ShardingSpherePreconditions.checkState(null == databaseName || 
privileges.filter(optional -> optional.hasPrivileges(databaseName)).isPresent(),
                 () -> new UnknownDatabaseException(databaseName));
         PrivilegeType privilegeType = 
PrivilegeTypeMapper.getPrivilegeType(sqlStatement);
-        ShardingSpherePreconditions.checkState(privileges.isPresent() && 
privileges.get().hasPrivileges(Collections.singleton(privilegeType)),
-                () -> new UnauthorizedOperationException(null == privilegeType 
? "" : privilegeType.name()));
+        ShardingSpherePreconditions.checkState(privileges.isPresent(), () -> 
new UnauthorizedOperationException(null == privilegeType ? "" : 
privilegeType.name()));
     }
 }

Reply via email to