fix: 删除并行流转换 Bean, 解决多线程下集合不安全问题.

pull/161/head
chen.ma 3 years ago
parent b1b82d9534
commit d11f1c86f1

@ -33,7 +33,7 @@ public class BeanUtil {
return Optional.ofNullable(sources) return Optional.ofNullable(sources)
.map(each -> { .map(each -> {
List<T> targetList = new ArrayList<T>(each.size()); List<T> targetList = new ArrayList<T>(each.size());
each.parallelStream() each.stream()
.forEach(item -> targetList.add(BEAN_MAPPER_BUILDER.map(item, clazz))); .forEach(item -> targetList.add(BEAN_MAPPER_BUILDER.map(item, clazz)));
return targetList; return targetList;
}) })
@ -44,7 +44,7 @@ public class BeanUtil {
return Optional.ofNullable(sources) return Optional.ofNullable(sources)
.map(each -> { .map(each -> {
Set<T> targetSize = new HashSet<T>(each.size()); Set<T> targetSize = new HashSet<T>(each.size());
each.parallelStream() each.stream()
.forEach(item -> targetSize.add(BEAN_MAPPER_BUILDER.map(item, clazz))); .forEach(item -> targetSize.add(BEAN_MAPPER_BUILDER.map(item, clazz)));
return targetSize; return targetSize;
}) })

Loading…
Cancel
Save