From 6db7fa6d468fbaf9fc36b3f60d05ecdc63cb5b89 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 15 Oct 2025 15:31:18 +0200 Subject: [PATCH] Add nullability annotations to tests in module/spring-boot-webflux-test See gh-47263 --- module/spring-boot-webflux-test/build.gradle | 4 ++++ .../boot/webflux/test/autoconfigure/ExampleIdConverter.java | 4 +++- .../test/autoconfigure/WebFluxTypeExcludeFilterTests.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/module/spring-boot-webflux-test/build.gradle b/module/spring-boot-webflux-test/build.gradle index 03c1d3c614e..7586454155a 100644 --- a/module/spring-boot-webflux-test/build.gradle +++ b/module/spring-boot-webflux-test/build.gradle @@ -39,3 +39,7 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic") } + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} diff --git a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java index 524b6a85f30..731881e17a1 100644 --- a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/ExampleIdConverter.java @@ -20,6 +20,8 @@ import java.util.Collections; import java.util.Set; import java.util.UUID; +import org.jspecify.annotations.Nullable; + import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.GenericConverter; import org.springframework.stereotype.Component; @@ -38,7 +40,7 @@ public class ExampleIdConverter implements GenericConverter { } @Override - public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + public @Nullable Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return null; } diff --git a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java index 7190c842534..7fd731e778d 100644 --- a/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java +++ b/module/spring-boot-webflux-test/src/test/java/org/springframework/boot/webflux/test/autoconfigure/WebFluxTypeExcludeFilterTests.java @@ -176,7 +176,7 @@ class WebFluxTypeExcludeFilterTests { @Override public Mono filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) { - return null; + return Mono.empty(); } }