DATACMNS-1271 - Streamlined implementation of AnnotationBasedPersistentProperty to avoid NullPointerExceptions.
We now use the annotation cache's ….computeIfAbsent(…) to avoid inconsistencies between ….contains(…) and ….get(…) in multi-threaded scenarios.
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.stream.Collector;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@@ -95,4 +96,15 @@ public interface StreamUtils {
|
||||
Function<T, V> valueFunction) {
|
||||
return MultiValueMapCollector.of(keyFunction, valueFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link Stream} for the given value returning an empty {@link Stream} if the value is {@literal null}.
|
||||
*
|
||||
* @param source can be {@literal null}.
|
||||
* @return a new {@link Stream} for the given value returning an empty {@link Stream} if the value is {@literal null}.
|
||||
* @since 2.0.6
|
||||
*/
|
||||
public static <T> Stream<T> fromNullable(@Nullable T source) {
|
||||
return source == null ? Stream.empty() : Stream.of(source);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user