From aac1845cacf398a89f5ab6144eae3cfd02bb7537 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 16 Sep 2025 15:03:40 +0200 Subject: [PATCH] Improve null-safety of core/spring-boot See gh-46926 --- .../ConfigurationPropertiesScanRegistrar.java | 6 ++++-- .../source/CachingConfigurationPropertySource.java | 2 +- .../properties/source/ConfigurationProperty.java | 3 +++ .../source/ConfigurationPropertyName.java | 10 +++++----- .../boot/diagnostics/AbstractFailureAnalyzer.java | 2 +- ...siveConfigurationPropertiesFailureAnalyzer.java | 4 ++-- .../boot/json/AbstractJsonParser.java | 4 ++-- .../springframework/boot/json/BasicJsonParser.java | 4 ++-- .../springframework/boot/json/GsonJsonParser.java | 5 +++-- .../boot/json/JacksonJsonParser.java | 4 ++-- .../org/springframework/boot/json/JsonParser.java | 6 ++++-- .../logging/DelegatingLoggingSystemFactory.java | 4 ++-- .../boot/logging/log4j2/ColorConverter.java | 2 +- .../log4j2/EnclosedInSquareBracketsConverter.java | 3 ++- .../logback/EnclosedInSquareBracketsConverter.java | 2 +- .../logback/LogbackLoggingSystemProperties.java | 2 +- .../StructuredLoggingJsonProperties.java | 9 +++++---- .../springframework/boot/origin/OriginLookup.java | 2 +- .../boot/ssl/jks/JksSslStoreDetails.java | 2 +- .../springframework/boot/ssl/pem/PemSslStore.java | 14 +++++++++----- .../boot/ssl/pem/PemSslStoreDetails.java | 4 ++-- .../boot/system/ApplicationPid.java | 2 +- .../support/SpringBootServletInitializer.java | 4 ++-- 23 files changed, 57 insertions(+), 43 deletions(-) diff --git a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java index 99233bdd898..6bae920b46f 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesScanRegistrar.java @@ -20,6 +20,8 @@ import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; +import org.jspecify.annotations.Nullable; + import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -50,9 +52,9 @@ class ConfigurationPropertiesScanRegistrar implements ImportBeanDefinitionRegist private final Environment environment; - private final ResourceLoader resourceLoader; + private final @Nullable ResourceLoader resourceLoader; - ConfigurationPropertiesScanRegistrar(Environment environment, ResourceLoader resourceLoader) { + ConfigurationPropertiesScanRegistrar(Environment environment, @Nullable ResourceLoader resourceLoader) { this.environment = environment; this.resourceLoader = resourceLoader; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/CachingConfigurationPropertySource.java b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/CachingConfigurationPropertySource.java index 134055506a6..e6910f3c98d 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/CachingConfigurationPropertySource.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/CachingConfigurationPropertySource.java @@ -38,7 +38,7 @@ interface CachingConfigurationPropertySource { * @return a {@link ConfigurationPropertyCaching} instance or {@code null} if the * source does not support caching. */ - static @Nullable ConfigurationPropertyCaching find(ConfigurationPropertySource source) { + static @Nullable ConfigurationPropertyCaching find(@Nullable ConfigurationPropertySource source) { if (source instanceof CachingConfigurationPropertySource cachingSource) { return cachingSource.getCaching(); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java index 5cfd4bc9475..10570d9b8e2 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java @@ -22,6 +22,7 @@ import org.springframework.boot.origin.Origin; import org.springframework.boot.origin.OriginProvider; import org.springframework.boot.origin.OriginTrackedValue; import org.springframework.core.style.ToStringCreator; +import org.springframework.lang.Contract; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; @@ -124,6 +125,7 @@ public final class ConfigurationProperty implements OriginProvider, Comparable !null") static @Nullable ConfigurationProperty of(ConfigurationPropertyName name, @Nullable OriginTrackedValue value) { if (value == null) { return null; @@ -131,6 +133,7 @@ public final class ConfigurationProperty implements OriginProvider, Comparable !null") static @Nullable ConfigurationProperty of(@Nullable ConfigurationPropertySource source, ConfigurationPropertyName name, @Nullable Object value, @Nullable Origin origin) { if (value == null) { diff --git a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 716e0cab5bc..b2d54716d9c 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -210,7 +210,7 @@ public final class ConfigurationPropertyName implements Comparable !null") - static @Nullable ConfigurationPropertyName of(CharSequence name, boolean returnNullIfInvalid) { + static @Nullable ConfigurationPropertyName of(@Nullable CharSequence name, boolean returnNullIfInvalid) { Elements elements = elementsOf(name, returnNullIfInvalid, ElementsParser.DEFAULT_CAPACITY); return (elements != null) ? new ConfigurationPropertyName(elements) : null; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzer.java b/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzer.java index 9ebf196ad5c..026bc5b7c4b 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzer.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/AbstractFailureAnalyzer.java @@ -61,7 +61,7 @@ public abstract class AbstractFailureAnalyzer implements Fa } @SuppressWarnings("unchecked") - protected final @Nullable E findCause(Throwable failure, Class type) { + protected final @Nullable E findCause(@Nullable Throwable failure, Class type) { while (failure != null) { if (type.isInstance(failure)) { return (E) failure; diff --git a/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java b/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java index 6e40c2e6a54..6e3080ad383 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java @@ -48,9 +48,9 @@ import org.springframework.core.env.PropertySource; class MutuallyExclusiveConfigurationPropertiesFailureAnalyzer extends AbstractFailureAnalyzer { - private final ConfigurableEnvironment environment; + private final @Nullable ConfigurableEnvironment environment; - MutuallyExclusiveConfigurationPropertiesFailureAnalyzer(Environment environment) { + MutuallyExclusiveConfigurationPropertiesFailureAnalyzer(@Nullable Environment environment) { this.environment = (ConfigurableEnvironment) environment; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java b/core/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java index bf08e2565a0..78e9a0000b8 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java @@ -34,11 +34,11 @@ import org.springframework.util.ReflectionUtils; */ public abstract class AbstractJsonParser implements JsonParser { - protected final Map parseMap(String json, Function> parser) { + protected final Map parseMap(@Nullable String json, Function> parser) { return trimParse(json, "{", parser); } - protected final List parseList(String json, Function> parser) { + protected final List parseList(@Nullable String json, Function> parser) { return trimParse(json, "[", parser); } 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 00957e63229..a2560c21561 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 @@ -44,12 +44,12 @@ public class BasicJsonParser extends AbstractJsonParser { private static final int MAX_DEPTH = 1000; @Override - public Map parseMap(String json) { + public Map parseMap(@Nullable String json) { return tryParse(() -> parseMap(json, (jsonToParse) -> parseMapInternal(0, jsonToParse)), Exception.class); } @Override - public List parseList(String json) { + public List parseList(@Nullable String json) { return tryParse(() -> parseList(json, (jsonToParse) -> parseListInternal(0, jsonToParse)), Exception.class); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java b/core/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java index 1424ff6946f..30c8aade943 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/json/GsonJsonParser.java @@ -22,6 +22,7 @@ import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; +import org.jspecify.annotations.Nullable; /** * Thin wrapper to adapt {@link Gson} to a {@link JsonParser}. @@ -40,13 +41,13 @@ public class GsonJsonParser extends AbstractJsonParser { private final Gson gson = new GsonBuilder().create(); @Override - public Map parseMap(String json) { + public Map parseMap(@Nullable String json) { return tryParse(() -> parseMap(json, (trimmed) -> this.gson.fromJson(trimmed, MAP_TYPE.getType())), Exception.class); } @Override - public List parseList(String json) { + public List parseList(@Nullable String json) { return tryParse(() -> parseList(json, (trimmed) -> this.gson.fromJson(trimmed, LIST_TYPE.getType())), Exception.class); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/json/JacksonJsonParser.java b/core/spring-boot/src/main/java/org/springframework/boot/json/JacksonJsonParser.java index 7187254f607..c41437d7452 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/json/JacksonJsonParser.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/json/JacksonJsonParser.java @@ -53,12 +53,12 @@ public class JacksonJsonParser extends AbstractJsonParser { } @Override - public Map parseMap(String json) { + public Map parseMap(@Nullable String json) { return tryParse(() -> getObjectMapper().readValue(json, MAP_TYPE), Exception.class); } @Override - public List parseList(String json) { + public List parseList(@Nullable String json) { return tryParse(() -> getObjectMapper().readValue(json, LIST_TYPE), Exception.class); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/json/JsonParser.java b/core/spring-boot/src/main/java/org/springframework/boot/json/JsonParser.java index 4d2f21a9329..be1041dec11 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/json/JsonParser.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/json/JsonParser.java @@ -19,6 +19,8 @@ package org.springframework.boot.json; import java.util.List; import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Parser that can read JSON formatted strings into {@link Map}s or {@link List}s. * @@ -37,7 +39,7 @@ public interface JsonParser { * @return the parsed JSON as a map * @throws JsonParseException if the JSON cannot be parsed */ - Map parseMap(String json) throws JsonParseException; + Map parseMap(@Nullable String json) throws JsonParseException; /** * Parse the specified JSON string into a List. @@ -45,6 +47,6 @@ public interface JsonParser { * @return the parsed JSON as a list * @throws JsonParseException if the JSON cannot be parsed */ - List parseList(String json) throws JsonParseException; + List parseList(@Nullable String json) throws JsonParseException; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/DelegatingLoggingSystemFactory.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/DelegatingLoggingSystemFactory.java index 7ed3a8ec1e3..f85859bef4e 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/DelegatingLoggingSystemFactory.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/DelegatingLoggingSystemFactory.java @@ -28,13 +28,13 @@ import org.jspecify.annotations.Nullable; */ class DelegatingLoggingSystemFactory implements LoggingSystemFactory { - private final @Nullable Function> delegates; + private final @Nullable Function> delegates; /** * Create a new {@link DelegatingLoggingSystemFactory} instance. * @param delegates a function that provides the delegates */ - DelegatingLoggingSystemFactory(@Nullable Function> delegates) { + DelegatingLoggingSystemFactory(@Nullable Function> delegates) { this.delegates = delegates; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 06472fac6c8..a75deece60f 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -120,7 +120,7 @@ public final class ColorConverter extends LogEventPatternConverter { * @param options the options * @return a new instance, or {@code null} if the options are invalid */ - public static @Nullable ColorConverter newInstance(Configuration config, @Nullable String[] options) { + public static @Nullable ColorConverter newInstance(@Nullable Configuration config, @Nullable String[] options) { if (options.length < 1) { LOGGER.error("Incorrect number of options on style. Expected at least 1, received {}", options.length); return null; diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/EnclosedInSquareBracketsConverter.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/EnclosedInSquareBracketsConverter.java index 640ee04151e..e56f6e7d89d 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/EnclosedInSquareBracketsConverter.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/EnclosedInSquareBracketsConverter.java @@ -67,7 +67,8 @@ public final class EnclosedInSquareBracketsConverter extends LogEventPatternConv * @param options the options * @return a new instance, or {@code null} if the options are invalid */ - public static @Nullable EnclosedInSquareBracketsConverter newInstance(Configuration config, String[] options) { + public static @Nullable EnclosedInSquareBracketsConverter newInstance(@Nullable Configuration config, + String[] options) { if (options.length < 1) { LOGGER.error("Incorrect number of options on style. Expected at least 1, received {}", options.length); return null; diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/EnclosedInSquareBracketsConverter.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/EnclosedInSquareBracketsConverter.java index 881a4fd58d1..18c8e85e19c 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/EnclosedInSquareBracketsConverter.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/EnclosedInSquareBracketsConverter.java @@ -32,7 +32,7 @@ import org.springframework.util.StringUtils; public class EnclosedInSquareBracketsConverter extends CompositeConverter { @Override - protected String transform(ILoggingEvent event, String in) { + protected String transform(ILoggingEvent event, @Nullable String in) { in = (!StringUtils.hasLength(in)) ? resolveFromFirstOption(event) : in; return (!StringUtils.hasLength(in)) ? "" : "[%s] ".formatted(in); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java index 7fccaf174e9..8ff938aa4d7 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystemProperties.java @@ -68,7 +68,7 @@ public class LogbackLoggingSystemProperties extends LoggingSystemProperties { * @since 3.2.0 */ public LogbackLoggingSystemProperties(Environment environment, - Function<@Nullable String, @Nullable String> defaultValueResolver, + @Nullable Function<@Nullable String, @Nullable String> defaultValueResolver, @Nullable BiConsumer setter) { super(environment, defaultValueResolver, setter); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java b/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java index e82fbf90007..6ff05dde52f 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java @@ -56,11 +56,11 @@ import org.springframework.util.Assert; * @author Yanming Zhou */ record StructuredLoggingJsonProperties(Set include, Set exclude, Map rename, - Map add, StackTrace stackTrace, Context context, + Map add, @Nullable StackTrace stackTrace, @Nullable Context context, Set>> customizer) { StructuredLoggingJsonProperties(Set include, Set exclude, Map rename, - Map add, StackTrace stackTrace, Context context, + Map add, @Nullable StackTrace stackTrace, @Nullable Context context, @Nullable Set>> customizer) { this.include = include; this.exclude = exclude; @@ -98,8 +98,9 @@ record StructuredLoggingJsonProperties(Set include, Set exclude, * @param includeCommonFrames whether common frames should be included * @param includeHashes whether stack trace hashes should be included */ - record StackTrace(@Nullable String printer, Root root, Integer maxLength, Integer maxThrowableDepth, - Boolean includeCommonFrames, Boolean includeHashes) { + record StackTrace(@Nullable String printer, @Nullable Root root, @Nullable Integer maxLength, + @Nullable Integer maxThrowableDepth, @Nullable Boolean includeCommonFrames, + @Nullable Boolean includeHashes) { @Nullable StackTracePrinter createPrinter() { String name = sanitizePrinter(); diff --git a/core/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java b/core/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java index 0900984beb0..9de2d73991b 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java @@ -47,7 +47,7 @@ public interface OriginLookup { * @return an {@link Origin} or {@code null} */ @SuppressWarnings("unchecked") - static @Nullable Origin getOrigin(Object source, K key) { + static @Nullable Origin getOrigin(@Nullable Object source, K key) { if (!(source instanceof OriginLookup)) { return null; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/ssl/jks/JksSslStoreDetails.java b/core/spring-boot/src/main/java/org/springframework/boot/ssl/jks/JksSslStoreDetails.java index 27114b77dec..f88468af6a5 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/ssl/jks/JksSslStoreDetails.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/ssl/jks/JksSslStoreDetails.java @@ -61,7 +61,7 @@ public record JksSslStoreDetails(@Nullable String type, @Nullable String provide * @param location the location * @return a new {@link JksSslStoreDetails} instance. */ - public static JksSslStoreDetails forLocation(String location) { + public static JksSslStoreDetails forLocation(@Nullable String location) { return new JksSslStoreDetails(null, null, location, null); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStore.java b/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStore.java index 21cdf0685c1..96187076412 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStore.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStore.java @@ -78,7 +78,9 @@ public interface PemSslStore { * @return a new {@link PemSslStore} instance */ default PemSslStore withAlias(@Nullable String alias) { - return of(type(), alias, password(), certificates(), privateKey()); + List certificates = certificates(); + Assert.notNull(certificates, "'certificates' must not be null"); + return of(type(), alias, password(), certificates, privateKey()); } /** @@ -87,7 +89,9 @@ public interface PemSslStore { * @return a new {@link PemSslStore} instance */ default PemSslStore withPassword(@Nullable String password) { - return of(type(), alias(), password, certificates(), privateKey()); + List certificates = certificates(); + Assert.notNull(certificates, "'certificates' must not be null"); + return of(type(), alias(), password, certificates, privateKey()); } /** @@ -123,7 +127,7 @@ public interface PemSslStore { * @param privateKey the private key * @return a new {@link PemSslStore} instance */ - static PemSslStore of(String type, List certificates, PrivateKey privateKey) { + static PemSslStore of(@Nullable String type, List certificates, @Nullable PrivateKey privateKey) { return of(type, null, null, certificates, privateKey); } @@ -134,7 +138,7 @@ public interface PemSslStore { * @param privateKey the private key * @return a new {@link PemSslStore} instance */ - static PemSslStore of(List certificates, PrivateKey privateKey) { + static PemSslStore of(List certificates, @Nullable PrivateKey privateKey) { return of(null, null, null, certificates, privateKey); } @@ -151,7 +155,7 @@ public interface PemSslStore { * @return a new {@link PemSslStore} instance */ static PemSslStore of(@Nullable String type, @Nullable String alias, @Nullable String password, - @Nullable List certificates, @Nullable PrivateKey privateKey) { + List certificates, @Nullable PrivateKey privateKey) { Assert.notEmpty(certificates, "'certificates' must not be empty"); return new PemSslStore() { diff --git a/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java b/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java index b319cba228c..e8243c32bda 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemSslStoreDetails.java @@ -151,7 +151,7 @@ public record PemSslStoreDetails(@Nullable String type, @Nullable String alias, * reference to the resource to load) * @return a new {@link PemSslStoreDetails} instance. */ - public static PemSslStoreDetails forCertificate(String certificate) { + public static PemSslStoreDetails forCertificate(@Nullable String certificate) { return forCertificates(certificate); } @@ -163,7 +163,7 @@ public record PemSslStoreDetails(@Nullable String type, @Nullable String alias, * @return a new {@link PemSslStoreDetails} instance. * @since 3.2.0 */ - public static PemSslStoreDetails forCertificates(String certificates) { + public static PemSslStoreDetails forCertificates(@Nullable String certificates) { return new PemSslStoreDetails(null, certificates, null); } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/core/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index f86fff7dc43..0e71c292b37 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -46,7 +46,7 @@ public class ApplicationPid { this.pid = currentProcessPid(); } - protected ApplicationPid(Long pid) { + protected ApplicationPid(@Nullable Long pid) { this.pid = pid; } diff --git a/core/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java b/core/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java index fc6aa581756..4304cca8b85 100644 --- a/core/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java +++ b/core/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializer.java @@ -151,7 +151,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit } } - protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) { + protected @Nullable WebApplicationContext createRootApplicationContext(ServletContext servletContext) { SpringApplicationBuilder builder = createSpringApplicationBuilder(); builder.main(getClass()); ApplicationContext parent = getExistingRootWebApplicationContext(servletContext); @@ -201,7 +201,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit * @param application the application to run * @return the {@link WebApplicationContext} */ - protected WebApplicationContext run(SpringApplication application) { + protected @Nullable WebApplicationContext run(SpringApplication application) { return (WebApplicationContext) application.run(); }