fix 修复 新语法 .toList() 返回不可变 List 类型导致序列化问题

This commit is contained in:
疯狂的狮子Li
2023-01-30 23:02:33 +08:00
parent e94ed91f0b
commit f0eae7cdb5
4 changed files with 15 additions and 11 deletions

View File

@ -30,7 +30,8 @@ public class StreamUtils {
if (CollUtil.isEmpty(collection)) {
return CollUtil.newArrayList();
}
return collection.stream().filter(function).toList();
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
return collection.stream().filter(function).collect(Collectors.toList());
}
/**
@ -70,7 +71,8 @@ public class StreamUtils {
if (CollUtil.isEmpty(collection)) {
return CollUtil.newArrayList();
}
return collection.stream().sorted(comparing).toList();
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
return collection.stream().sorted(comparing).collect(Collectors.toList());
}
/**
@ -188,7 +190,8 @@ public class StreamUtils {
.stream()
.map(function)
.filter(Objects::nonNull)
.toList();
// 注意此处不要使用 .toList() 新语法 因为返回的是不可变List 会导致序列化问题
.collect(Collectors.toList());
}
/**