From 065c463cef11838b40d082d835c46bde5193be4f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 1 May 2026 08:39:18 +0100 Subject: [PATCH] Improve nullability of TestPropertyValues Closes gh-50269 --- .../boot/test/util/TestPropertyValues.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index fc9eb2d8315..861b6af4d4c 100644 --- a/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -100,7 +100,7 @@ public final class TestPropertyValues { * @since 2.4.0 */ public TestPropertyValues and(@Nullable Map map) { - return (map != null) ? and(map.entrySet().stream(), Pair::fromMapEntry) : this; + return (map != null) ? and(map.entrySet().stream(), Pair::fromNonNullValueMapEntry) : this; } /** @@ -257,7 +257,7 @@ public final class TestPropertyValues { * @return the new instance */ public static TestPropertyValues of(@Nullable Map map) { - return (map != null) ? of(map.entrySet().stream(), Pair::fromMapEntry) : empty(); + return (map != null) ? of(map.entrySet().stream(), Pair::fromNonNullValueMapEntry) : empty(); } /** @@ -363,6 +363,10 @@ public final class TestPropertyValues { return of(entry.getKey(), entry.getValue()); } + private static Pair fromNonNullValueMapEntry(Map.Entry entry) { + return of(entry.getKey(), entry.getValue()); + } + /** * Factory method to create a {@link Pair} from a name and value. * @param name the name