Skip to content

Commit 7530890

Browse files
quaffmp911de
authored andcommitted
Use mutable list to collect items from Stream for reversal.
>> There are no guarantees on the type, mutability, serializability, or thread-safety of the List returned `Collector.toList()` doesn't guarantee mutability, then passing it to `Collections.reverse()` is not safe. Signed-off-by: Yanming Zhou <[email protected]> Closes #3304
1 parent e611c2f commit 7530890

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/org/springframework/data/convert/CustomConversions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public CustomConversions(ConverterConfiguration converterConfiguration) {
124124
converterConfiguration.getStoreConversions(), converterConfiguration.getUserConverters()).stream()
125125
.filter(this::isSupportedConverter).filter(this::shouldRegister)
126126
.map(ConverterRegistrationIntent::getConverterRegistration).map(this::register).distinct()
127-
.collect(Collectors.toList());
127+
.collect(Collectors.toCollection(ArrayList::new));
128128

129129
Collections.reverse(registeredConverters);
130130

src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private List<EvaluationContextExtensionAdapter> toAdapters(
189189
return extensions.stream()//
190190
.sorted(AnnotationAwareOrderComparator.INSTANCE)//
191191
.map(it -> new EvaluationContextExtensionAdapter(it, getOrCreateInformation(it))) //
192-
.collect(Collectors.toList());
192+
.collect(Collectors.toCollection(ArrayList::new));
193193
}
194194

195195
/**

0 commit comments

Comments
 (0)