diff --git a/CHANGELOG.md b/CHANGELOG.md index b5186e512..15b0e99b7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.29(2024-06-02) +# 5.8.29(2024-06-04) ### 🐣新特性 * 【core 】 DateUtil增加offsetYear方法 * 【core 】 ListUtil增加move方法(issue#3603@Github) +* 【core 】 CollUtil.subtract增加空判定(issue#3605@Github) ### 🐞Bug修复 * 【core 】 修复AnnotationUtil可能的空指针错误 diff --git a/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java b/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java index b2fe32234..6c295a83f 100755 --- a/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java @@ -361,6 +361,10 @@ public class CollUtil { * @return 单差集 */ public static Collection subtract(Collection coll1, Collection coll2) { + if(isEmpty(coll1) || isEmpty(coll2)){ + return coll1; + } + Collection result = ObjectUtil.clone(coll1); try { if (null == result) {