mirror of
https://gitee.com/dromara/hutool.git
synced 2025-10-07 23:24:43 +08:00
IoUtil.writeObjects
判空避免空指针(issue#4049@Github)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.41(2025-08-29)
|
||||
# 5.8.41(2025-08-30)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 增加`WeakKeyValueConcurrentMap`及其关联类,同时废弃`WeakConcurrentMap`并替换(issue#4039@Github)
|
||||
@@ -10,6 +10,7 @@
|
||||
* 【core 】 `ObjectUtil`增加`apply`方法
|
||||
* 【core 】 `ReferenceUtil`增加`get`方法
|
||||
* 【db 】 `Condition`增加构造方法支持BETWEEN(issue#4041@Github)
|
||||
* 【core 】 `IoUtil.writeObjects`判空避免空指针(issue#4049@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复`ReflectUtil`中因class和Method关联导致的缓存无法回收问题(issue#4039@Github)
|
||||
|
@@ -6,6 +6,7 @@ import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.io.copy.ReaderWriterCopier;
|
||||
import cn.hutool.core.io.copy.StreamCopier;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -1071,6 +1072,10 @@ public class IoUtil extends NioUtil {
|
||||
public static void writeObjects(OutputStream out, boolean isCloseOut, Serializable... contents) throws IORuntimeException {
|
||||
ObjectOutputStream osw = null;
|
||||
try {
|
||||
if(ArrayUtil.isEmpty( contents)){
|
||||
return;
|
||||
}
|
||||
|
||||
osw = out instanceof ObjectOutputStream ? (ObjectOutputStream) out : new ObjectOutputStream(out);
|
||||
for (Object content : contents) {
|
||||
if (content != null) {
|
||||
|
Reference in New Issue
Block a user