修复BeanUtil.isCommonFieldsEqual判空导致的问题

This commit is contained in:
Looly 2023-07-05 09:45:48 +08:00
parent dffba89e50
commit 3cbbbcfe1b
2 changed files with 9 additions and 6 deletions

View File

@ -2,7 +2,7 @@
# 🚀Changelog # 🚀Changelog
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.8.21(2023-07-03) # 5.8.21(2023-07-05)
### 🐣新特性 ### 🐣新特性
* 【core 】 list 为空时CollUtil.max等返回null而非异常pr#1027@Gitee * 【core 】 list 为空时CollUtil.max等返回null而非异常pr#1027@Gitee
@ -20,6 +20,7 @@
* 【core 】 修复PathUtil.getMimeType可能造成的异常issue#3179@Github * 【core 】 修复PathUtil.getMimeType可能造成的异常issue#3179@Github
* 【core 】 修复Pair序列化转换无效问题issue#I7GPGX@Github * 【core 】 修复Pair序列化转换无效问题issue#I7GPGX@Github
* 【core 】 修复TypeUtil.getTypeArgument对实现接口获取不全面问题issue#I7CRIW@Gitee * 【core 】 修复TypeUtil.getTypeArgument对实现接口获取不全面问题issue#I7CRIW@Gitee
* 【core 】 修复BeanUtil.isCommonFieldsEqual判空导致的问题
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.8.20(2023-06-16) # 5.8.20(2023-06-16)

View File

@ -994,17 +994,19 @@ public class BeanUtil {
return false; return false;
} }
Map<String, Object> sourceFieldsMap = BeanUtil.beanToMap(source); final Map<String, Object> sourceFieldsMap = BeanUtil.beanToMap(source);
Map<String, Object> targetFieldsMap = BeanUtil.beanToMap(target); final Map<String, Object> targetFieldsMap = BeanUtil.beanToMap(target);
Set<String> sourceFields = sourceFieldsMap.keySet(); final Set<String> sourceFields = sourceFieldsMap.keySet();
sourceFields.removeAll(Arrays.asList(ignoreProperties)); sourceFields.removeAll(Arrays.asList(ignoreProperties));
for (String field : sourceFields) { for (String field : sourceFields) {
if(sourceFieldsMap.containsKey(field) && targetFieldsMap.containsKey(field)){
if (ObjectUtil.notEqual(sourceFieldsMap.get(field), targetFieldsMap.get(field))) { if (ObjectUtil.notEqual(sourceFieldsMap.get(field), targetFieldsMap.get(field))) {
return false; return false;
} }
} }
}
return true; return true;
} }