* Reset nacos roles, permissions during reloading role info from database * Add volatile to guarantee visibility in threads
This commit is contained in:
parent
d19b441540
commit
377f778711
@ -64,11 +64,11 @@ public class NacosRoleServiceImpl {
|
||||
@Autowired
|
||||
private PermissionPersistService permissionPersistService;
|
||||
|
||||
private final Set<String> roleSet = new ConcurrentHashSet<>();
|
||||
private volatile Set<String> roleSet = new ConcurrentHashSet<>();
|
||||
|
||||
private final Map<String, List<RoleInfo>> roleInfoMap = new ConcurrentHashMap<>();
|
||||
private volatile Map<String, List<RoleInfo>> roleInfoMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final Map<String, List<PermissionInfo>> permissionInfoMap = new ConcurrentHashMap<>();
|
||||
private volatile Map<String, List<PermissionInfo>> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user