From 8e65899380857a8a67916a37f707a8f8791ccc0f Mon Sep 17 00:00:00 2001 From: Lei Zhiyuan Date: Fri, 24 Nov 2023 10:55:11 +0800 Subject: [PATCH] [ISSUE #7579] Fix globalWhiteRemoteAddressStrategy cocurrent bug --- .../apache/rocketmq/acl/plain/PlainPermissionManager.java | 5 +++-- 1 file changed, 3 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 345aed06c5a..6a1d826837c 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 @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.acl.PermissionChecker; @@ -62,7 +63,7 @@ public class PlainPermissionManager { private Map accessKeyTable = new HashMap<>(); - private List globalWhiteRemoteAddressStrategy = new ArrayList<>(); + private List globalWhiteRemoteAddressStrategy = new CopyOnWriteArrayList<>(); private RemoteAddressStrategyFactory remoteAddressStrategyFactory = new RemoteAddressStrategyFactory(); @@ -115,7 +116,7 @@ public void load() { Map> aclPlainAccessResourceMap = new HashMap<>(); Map accessKeyTable = new HashMap<>(); - List globalWhiteRemoteAddressStrategy = new ArrayList<>(); + List globalWhiteRemoteAddressStrategy = new CopyOnWriteArrayList<>(); Map> globalWhiteRemoteAddressStrategyMap = new HashMap<>(); Map dataVersionMap = new HashMap<>();