修复数据加密bug:当查询的列表为空时,解密方法报数组越界的异常

This commit is contained in:
mayuanfei 2023-03-07 15:39:55 +08:00
parent 4b07faf89a
commit f6d4e23bf6
2 changed files with 10 additions and 2 deletions

View File

@ -60,8 +60,12 @@ public class MybatisDecryptInterceptor implements Interceptor {
return;
}
if (sourceObject instanceof List<?>) {
List<?> sourceList = (List<?>) sourceObject;
if(CollectionUtil.isEmpty(sourceList)) {
return;
}
// 判断第一个元素是否含有注解如果没有直接返回提高效率
Object firstItem = ((List<?>) sourceObject).get(0);
Object firstItem = sourceList.get(0);
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
return;
}

View File

@ -71,8 +71,12 @@ public class MybatisEncryptInterceptor implements Interceptor {
return;
}
if (sourceObject instanceof List<?>) {
List<?> sourceList = (List<?>) sourceObject;
if(CollectionUtil.isEmpty(sourceList)) {
return;
}
// 判断第一个元素是否含有注解如果没有直接返回提高效率
Object firstItem = ((List<?>) sourceObject).get(0);
Object firstItem = sourceList.get(0);
if (CollectionUtil.isEmpty(encryptorManager.getFieldCache(firstItem.getClass()))) {
return;
}