From dff33aec5570b5aee17c2a3a404bd354f0c8662f Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Fri, 26 Jun 2026 08:59:53 +0800 Subject: [PATCH 1/2] Remove unnecessary `@Nullable`s from local variable declarations See gh-50866 Signed-off-by: Yanming Zhou --- .../autoconfigure/jsontest/app/ExampleJacksonComponent.java | 5 ++--- .../metrics/autoconfigure/PropertiesMeterFilter.java | 2 +- .../smoketest/integration/producer/ProducerApplication.java | 3 +-- .../java/smoketest/parent/producer/ProducerApplication.java | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleJacksonComponent.java b/module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleJacksonComponent.java index bfce0b131e80..366bae480fe5 100644 --- a/module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleJacksonComponent.java +++ b/module/spring-boot-jackson/src/test/java/org/springframework/boot/jackson/autoconfigure/jsontest/app/ExampleJacksonComponent.java @@ -19,7 +19,6 @@ import java.util.Date; import java.util.UUID; -import org.jspecify.annotations.Nullable; import tools.jackson.core.JsonGenerator; import tools.jackson.core.JsonParser; import tools.jackson.databind.DeserializationContext; @@ -45,11 +44,11 @@ static class Serializer extends ObjectValueSerializer { @Override protected void serializeObject(ExampleCustomObject value, JsonGenerator jgen, SerializationContext context) { jgen.writeStringProperty("value", value.value()); - @Nullable Date date = value.date(); + Date date = value.date(); if (date != null) { jgen.writeNumberProperty("date", date.getTime()); } - @Nullable UUID uuid = value.uuid(); + UUID uuid = value.uuid(); if (uuid != null) { jgen.writeStringProperty("uuid", uuid.toString()); } diff --git a/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java b/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java index 2c2e8dbae36b..7ad6299f1ed0 100644 --- a/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java +++ b/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/PropertiesMeterFilter.java @@ -125,7 +125,7 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC if (values.isEmpty()) { return defaultValue; } - @Nullable T result = doLookup(values, id); + T result = doLookup(values, id); return (result != null) ? result : values.getOrDefault("all", defaultValue); } diff --git a/smoke-test/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java b/smoke-test/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java index d54da02b7277..7e766e57a2b9 100644 --- a/smoke-test/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java +++ b/smoke-test/spring-boot-smoke-test-integration/src/test/java/smoketest/integration/producer/ProducerApplication.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.FileOutputStream; -import org.jspecify.annotations.Nullable; import smoketest.integration.ServiceProperties; import org.springframework.boot.ApplicationArguments; @@ -41,7 +40,7 @@ public ProducerApplication(ServiceProperties serviceProperties) { @Override public void run(ApplicationArguments args) throws Exception { - @Nullable File inputDir = this.serviceProperties.getInputDir(); + File inputDir = this.serviceProperties.getInputDir(); Assert.notNull(inputDir, "No inputDir configured"); inputDir.mkdirs(); if (!args.getNonOptionArgs().isEmpty()) { diff --git a/smoke-test/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java b/smoke-test/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java index 03e2149ea842..087d6f7ff556 100644 --- a/smoke-test/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java +++ b/smoke-test/spring-boot-smoke-test-parent-context/src/test/java/smoketest/parent/producer/ProducerApplication.java @@ -19,7 +19,6 @@ import java.io.File; import java.io.FileOutputStream; -import org.jspecify.annotations.Nullable; import smoketest.parent.ServiceProperties; import org.springframework.boot.ApplicationArguments; @@ -41,7 +40,7 @@ public ProducerApplication(ServiceProperties serviceProperties) { @Override public void run(ApplicationArguments args) throws Exception { - @Nullable File inputDir = this.serviceProperties.getInputDir(); + File inputDir = this.serviceProperties.getInputDir(); Assert.notNull(inputDir, "No inputDir configured"); inputDir.mkdirs(); if (!args.getNonOptionArgs().isEmpty()) { From ecacc0aa1e5c9ba251aac076a759dea24a66256b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Sun, 28 Jun 2026 10:39:27 +0100 Subject: [PATCH 2/2] Polish "Remove unnecessary `@Nullable`s from local variable declarations" See gh-50866 Signed-off-by: Andy Wilkinson --- .../java/org/springframework/boot/json/BasicJsonParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java b/core/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java index 37ecad7445b0..dc01f6827b05 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java @@ -82,7 +82,7 @@ private Map parseMapInternal(int nesting, String json) { Map map = new LinkedHashMap<>(); json = trimEdges(json, '{', '}').trim(); for (String pair : tokenize(json)) { - String @Nullable [] split = StringUtils.split(pair, ":"); + String[] split = StringUtils.split(pair, ":"); Assert.state(split != null, () -> "Unable to parse '%s'".formatted(pair)); @Nullable String[] rawElement = StringUtils.trimArrayElements(split); String rawKey = rawElement[0];