From 9db9648539115c0314a3a8311e2feee8f9d26b43 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 4 Jun 2024 08:47:39 +0800 Subject: [PATCH] =?UTF-8?q?CollUtil.subtract=E5=A2=9E=E5=8A=A0=E7=A9=BA?= =?UTF-8?q?=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/core/collection/CollUtil.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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) {