From 3f6112fcfa7888f3da76d576bd7b7f4d718fa28b Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 2 Apr 2020 11:03:08 +0800 Subject: [PATCH] add null check --- CHANGELOG.md | 2 ++ .../src/main/java/cn/hutool/core/collection/CollUtil.java | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9258b2f..a6c1dfaa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ * 【json 】 JSONObject和JSONArray增加set方法,标识put弃用 * 【http 】 增加SimpleHttpServer * 【script 】 增加createXXXScript,区别单例 +* 【core 】 修改FileUtil.writeFileToStream等方法返回值为long +* 【core 】 CollUtil.split增加空集合判定(issue#814@Github) ### Bug修复 * 【extra 】 修复SpringUtil使用devtools重启报错问题 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 186caf969..5a92c8fa6 100644 --- a/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/collection/CollUtil.java @@ -21,7 +21,6 @@ import cn.hutool.core.util.TypeUtil; import java.lang.reflect.Type; import java.util.AbstractCollection; -import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -824,7 +823,7 @@ public class CollUtil { /** * 创建Map
- * 传入抽象Map{@link AbstractMap}和{@link Map}类将默认创建{@link HashMap} + * 传入AbstractMap和{@link Map}类将默认创建{@link HashMap} * * @param map键类型 * @param map值类型 @@ -923,6 +922,9 @@ public class CollUtil { */ public static List> split(Collection collection, int size) { final List> result = new ArrayList<>(); + if (CollUtil.isEmpty(collection)) { + return result; + } ArrayList subList = new ArrayList<>(size); for (T t : collection) {