You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/05/26 00:39:24 UTC
[rocketmq] branch develop updated: [ISSUE#6595] Fix NPE and repeat access key log (#6596)
This is an automated email from the ASF dual-hosted git repository.
jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 330d56b2cf [ISSUE#6595] Fix NPE and repeat access key log (#6596)
330d56b2cf is described below
commit 330d56b2cf93d63fa602f7c24dcad955783266f3
Author: hiyo <77...@users.noreply.github.com>
AuthorDate: Fri May 26 08:38:59 2023 +0800
[ISSUE#6595] Fix NPE and repeat access key log (#6596)
* [ISSUE#6595] fix NPE and repeat access key log
* optimize code
---
.../java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
index 748f3d5846..f6699fa13b 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
@@ -243,6 +243,8 @@ public class PlainPermissionManager {
if (oldPath == null || aclFilePath.equals(oldPath)) {
plainAccessResourceMap.put(plainAccessResource.getAccessKey(), plainAccessResource);
this.accessKeyTable.put(plainAccessResource.getAccessKey(), aclFilePath);
+ } else {
+ log.warn("The accessKey {} is repeated in multiple ACL files", plainAccessResource.getAccessKey());
}
}
}
@@ -613,8 +615,8 @@ public class PlainPermissionManager {
// Check the white addr for accessKey
String aclFileName = accessKeyTable.get(plainAccessResource.getAccessKey());
- PlainAccessResource ownedAccess = aclPlainAccessResourceMap.get(aclFileName).get(plainAccessResource.getAccessKey());
- if (null == ownedAccess) {
+ PlainAccessResource ownedAccess = aclPlainAccessResourceMap.getOrDefault(aclFileName, new HashMap<>()).get(plainAccessResource.getAccessKey());
+ if (ownedAccess == null) {
throw new AclException(String.format("No PlainAccessResource for accessKey=%s", plainAccessResource.getAccessKey()));
}
if (ownedAccess.getRemoteAddressStrategy().match(plainAccessResource)) {