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

justinchen pushed a commit to branch open-npe
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/open-npe by this push:
     new b28ae7f7c8c fix
b28ae7f7c8c is described below

commit b28ae7f7c8ccfd011d53212f5f6920a0bb0e9563
Author: Caideyipi <[email protected]>
AuthorDate: Thu Apr 16 18:39:58 2026 +0800

    fix
---
 .../org/apache/iotdb/db/auth/AuthorityChecker.java |  4 ++--
 .../iotdb/db/auth/ClusterAuthorityFetcher.java     | 23 +++++++++++++---------
 .../apache/iotdb/db/auth/IAuthorityFetcher.java    |  2 +-
 .../execution/config/TableConfigTaskVisitor.java   |  5 +----
 .../execution/config/TreeConfigTaskVisitor.java    | 15 +++++---------
 5 files changed, 23 insertions(+), 26 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
index fa7edec953c..eef9d9277b4 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
@@ -138,11 +138,11 @@ public class AuthorityChecker {
   }
 
   public static User getUser(String username) {
-    return authorityFetcher.get().getUser(username);
+    return authorityFetcher.get().getUser(username, false);
   }
 
   public static Optional<Long> getUserId(String username) {
-    User user = authorityFetcher.get().getUser(username);
+    User user = authorityFetcher.get().getUser(username, false);
     return Optional.ofNullable(user == null ? null : user.getUserId());
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
index 325476174c6..f255d30385b 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/ClusterAuthorityFetcher.java
@@ -32,6 +32,7 @@ import org.apache.iotdb.commons.conf.CommonConfig;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.consensus.ConfigRegionId;
 import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.path.PathPatternTree;
@@ -172,7 +173,7 @@ public class ClusterAuthorityFetcher implements 
IAuthorityFetcher {
       return posList;
     }
     checkCacheAvailable();
-    User user = getUser(username);
+    User user = getUser(username, true);
     if (user.isOpenIdUser()) {
       return posList;
     }
@@ -443,13 +444,12 @@ public class ClusterAuthorityFetcher implements 
IAuthorityFetcher {
       Object authorStatement, String username, boolean isRelational, Runnable 
successCallback) {
 
     if (isUnlockStatement(authorStatement, isRelational)) {
-      SettableFuture<ConfigTaskResult> future = SettableFuture.create();
-      User user = getUser(username);
-      if (user == null) {
-        future.setException(
-            new IoTDBException(
-                String.format("User %s does not exist", username),
-                TSStatusCode.USER_NOT_EXIST.getStatusCode()));
+      final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+      final User user;
+      try {
+        user = getUser(username, false);
+      } catch (final IoTDBRuntimeException e) {
+        future.setException(e);
         return future;
       }
       String loginAddr =
@@ -593,7 +593,8 @@ public class ClusterAuthorityFetcher implements 
IAuthorityFetcher {
     }
   }
 
-  public User getUser(String userName) {
+  @Override
+  public User getUser(String userName, final boolean force) {
     checkCacheAvailable();
     User user = iAuthorCache.getUserCache(userName);
     if (user != null) {
@@ -616,6 +617,10 @@ public class ClusterAuthorityFetcher implements 
IAuthorityFetcher {
         }
       }
     }
+    if (user == null && force) {
+      throw new IoTDBRuntimeException(
+          "User " + userName + " does not exist", 
TSStatusCode.USER_NOT_EXIST.getStatusCode());
+    }
     return user;
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/IAuthorityFetcher.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/IAuthorityFetcher.java
index 30267987895..b14d5c599c1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/IAuthorityFetcher.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/auth/IAuthorityFetcher.java
@@ -86,5 +86,5 @@ public interface IAuthorityFetcher {
 
   void refreshToken();
 
-  User getUser(String username);
+  User getUser(String username, final boolean force);
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
index 0bb2efa9fd5..1b0ea2c75e8 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -1491,10 +1491,7 @@ public class TableConfigTaskVisitor extends 
AstVisitor<IConfigTask, MPPQueryCont
   }
 
   private void visitUpdateUser(RelationalAuthorStatement node) {
-    User user = 
AuthorityChecker.getAuthorityFetcher().getUser(node.getUserName());
-    if (user == null) {
-      throw new SemanticException("User " + node.getUserName() + " not found");
-    }
+    final User user = 
AuthorityChecker.getAuthorityFetcher().getUser(node.getUserName(), true);
     node.setOldPassword(user.getPassword());
   }
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
index 362982f645c..4e33c8240b4 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
@@ -22,7 +22,6 @@ package org.apache.iotdb.db.queryengine.plan.execution.config;
 import org.apache.iotdb.common.rpc.thrift.Model;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.audit.UserEntity;
-import org.apache.iotdb.commons.auth.entity.User;
 import org.apache.iotdb.commons.exception.auth.AccessDeniedException;
 import org.apache.iotdb.commons.executable.ExecutableManager;
 import org.apache.iotdb.commons.path.PartialPath;
@@ -340,18 +339,14 @@ public class TreeConfigTaskVisitor extends 
StatementVisitor<IConfigTask, MPPQuer
   }
 
   private void visitUpdateUser(AuthorStatement statement) {
-    User user = 
AuthorityChecker.getAuthorityFetcher().getUser(statement.getUserName());
-    if (user == null) {
-      throw new SemanticException("User " + statement.getUserName() + " not 
found");
-    }
-    statement.setPassWord(user.getPassword());
+    statement.setPassWord(
+        AuthorityChecker.getAuthorityFetcher()
+            .getUser(statement.getUserName(), true)
+            .getPassword());
   }
 
   private void visitRenameUser(AuthorStatement statement) {
-    User user = 
AuthorityChecker.getAuthorityFetcher().getUser(statement.getUserName());
-    if (user == null) {
-      throw new SemanticException("User " + statement.getUserName() + " not 
found");
-    }
+    AuthorityChecker.getAuthorityFetcher().getUser(statement.getUserName(), 
true);
   }
 
   @Override

Reply via email to