add null check

This commit is contained in:
Looly 2020-04-02 11:03:08 +08:00
parent b2201873ea
commit 3f6112fcfa
2 changed files with 6 additions and 2 deletions

View File

@ -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重启报错问题

View File

@ -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<br>
* 传入抽象Map{@link AbstractMap}{@link Map}类将默认创建{@link HashMap}
* 传入AbstractMap和{@link Map}类将默认创建{@link HashMap}
*
* @param <K> map键类型
* @param <V> map值类型
@ -923,6 +922,9 @@ public class CollUtil {
*/
public static <T> List<List<T>> split(Collection<T> collection, int size) {
final List<List<T>> result = new ArrayList<>();
if (CollUtil.isEmpty(collection)) {
return result;
}
ArrayList<T> subList = new ArrayList<>(size);
for (T t : collection) {