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 <zhouyanming@gmail.com>
Closes #3304
This commit is contained in:
Yanming Zhou
2025-06-03 16:23:42 +08:00
committed by Mark Paluch
parent 5d5ef3602d
commit 6d50ccbe3d
2 changed files with 2 additions and 2 deletions

View File

@@ -133,7 +133,7 @@ public class CustomConversions {
converterConfiguration.getStoreConversions(), converterConfiguration.getUserConverters()).stream()
.filter(this::isSupportedConverter).filter(this::shouldRegister)
.map(ConverterRegistrationIntent::getConverterRegistration).map(this::register).distinct()
.collect(Collectors.toList());
.collect(Collectors.toCollection(ArrayList::new));
Collections.reverse(registeredConverters);

View File

@@ -189,7 +189,7 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex
return extensions.stream()//
.sorted(AnnotationAwareOrderComparator.INSTANCE)//
.map(it -> new EvaluationContextExtensionAdapter(it, getOrCreateInformation(it))) //
.collect(Collectors.toList());
.collect(Collectors.toCollection(ArrayList::new));
}
/**