Browse Source

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
3.4.x
Yanming Zhou 8 months ago committed by Mark Paluch
parent
commit
200c091b34
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 2
      src/main/java/org/springframework/data/convert/CustomConversions.java
  2. 2
      src/main/java/org/springframework/data/spel/ExtensionAwareEvaluationContextProvider.java

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

@ -124,7 +124,7 @@ public class CustomConversions { @@ -124,7 +124,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);

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

@ -189,7 +189,7 @@ public class ExtensionAwareEvaluationContextProvider implements EvaluationContex @@ -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));
}
/**

Loading…
Cancel
Save