From 3eb2f3447f8e62a79b1cf6a352eac87284302694 Mon Sep 17 00:00:00 2001 From: caiti Date: Tue, 17 May 2022 21:54:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E5=88=86=E9=85=8D=E8=A7=92=E8=89=B2=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=BC=9A=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/permission/PermissionServiceImpl.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java index d213fc111..847450783 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java @@ -8,8 +8,8 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; -import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; @@ -248,7 +248,12 @@ public class PermissionServiceImpl implements PermissionService { @Override public Set getUserRoleIdsFromCache(Long userId, Collection roleStatuses) { - Set roleIds = new HashSet<>(userRoleCache.get(userId)); + Set cacheRoleIds = userRoleCache.get(userId); + // 创建用户的时候没有分配角色,会存在空指针异常 + if (cacheRoleIds == null || cacheRoleIds.isEmpty()) { + return Collections.emptySet(); + } + Set roleIds = new HashSet<>(cacheRoleIds); // 过滤角色状态 if (CollectionUtil.isNotEmpty(roleStatuses)) { roleIds.removeIf(roleId -> { From 92d7a701b55ae86247dd46e586a5cd1243937005 Mon Sep 17 00:00:00 2001 From: caiti Date: Tue, 17 May 2022 22:00:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8CollUtil.isEmpty?= =?UTF-8?q?=E5=88=A4=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/system/service/permission/PermissionServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java index 847450783..9c71e8bdb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java @@ -250,7 +250,7 @@ public class PermissionServiceImpl implements PermissionService { public Set getUserRoleIdsFromCache(Long userId, Collection roleStatuses) { Set cacheRoleIds = userRoleCache.get(userId); // 创建用户的时候没有分配角色,会存在空指针异常 - if (cacheRoleIds == null || cacheRoleIds.isEmpty()) { + if (CollUtil.isEmpty(cacheRoleIds)) { return Collections.emptySet(); } Set roleIds = new HashSet<>(cacheRoleIds);