diff --git a/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java b/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java index 2d9b66aab..0f4a268ca 100644 --- a/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java +++ b/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java @@ -64,11 +64,11 @@ public class NacosRoleServiceImpl { @Autowired private PermissionPersistService permissionPersistService; - private final Set roleSet = new ConcurrentHashSet<>(); + private volatile Set roleSet = new ConcurrentHashSet<>(); - private final Map> roleInfoMap = new ConcurrentHashMap<>(); + private volatile Map> roleInfoMap = new ConcurrentHashMap<>(); - private final Map> permissionInfoMap = new ConcurrentHashMap<>(); + private volatile Map> permissionInfoMap = new ConcurrentHashMap<>(); @Scheduled(initialDelay = 5000, fixedDelay = 15000) private void reload() { @@ -95,9 +95,9 @@ public class NacosRoleServiceImpl { tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems()); } - roleSet.addAll(tmpRoleSet); - roleInfoMap.putAll(tmpRoleInfoMap); - permissionInfoMap.putAll(tmpPermissionInfoMap); + roleSet = tmpRoleSet; + roleInfoMap = tmpRoleInfoMap; + permissionInfoMap = tmpPermissionInfoMap; } catch (Exception e) { Loggers.AUTH.warn("[LOAD-ROLES] load failed", e); }