* 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
|
@Autowired
|
||||||
private PermissionPersistService permissionPersistService;
|
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)
|
@Scheduled(initialDelay = 5000, fixedDelay = 15000)
|
||||||
private void reload() {
|
private void reload() {
|
||||||
@ -95,9 +95,9 @@ public class NacosRoleServiceImpl {
|
|||||||
tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems());
|
tmpPermissionInfoMap.put(role, permissionInfoPage.getPageItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
roleSet.addAll(tmpRoleSet);
|
roleSet = tmpRoleSet;
|
||||||
roleInfoMap.putAll(tmpRoleInfoMap);
|
roleInfoMap = tmpRoleInfoMap;
|
||||||
permissionInfoMap.putAll(tmpPermissionInfoMap);
|
permissionInfoMap = tmpPermissionInfoMap;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Loggers.AUTH.warn("[LOAD-ROLES] load failed", e);
|
Loggers.AUTH.warn("[LOAD-ROLES] load failed", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user