Add nullability annotations to module/spring-boot-actuator-autoconfigure

See gh-46587
This commit is contained in:
Moritz Halbritter
2025-07-29 16:25:22 +02:00
parent 50920f223c
commit 1fb95fbd18
60 changed files with 269 additions and 98 deletions
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure;
import java.lang.annotation.Annotation;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@@ -25,6 +27,7 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.Assert;
/**
* Base endpoint element condition. An element can be disabled globally through the
@@ -49,6 +52,7 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition {
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
AnnotationAttributes annotationAttributes = AnnotationAttributes
.fromMap(metadata.getAnnotationAttributes(this.annotationType.getName()));
Assert.state(annotationAttributes != null, "'annotationAttributes' must not be null");
String endpointName = annotationAttributes.getString("value");
ConditionOutcome outcome = getEndpointOutcome(context, endpointName);
if (outcome != null) {
@@ -57,7 +61,7 @@ public abstract class OnEndpointElementCondition extends SpringBootCondition {
return getDefaultOutcome(context, annotationAttributes);
}
protected ConditionOutcome getEndpointOutcome(ConditionContext context, String endpointName) {
protected @Nullable ConditionOutcome getEndpointOutcome(ConditionContext context, String endpointName) {
Environment environment = context.getEnvironment();
String enabledProperty = this.prefix + endpointName + ".enabled";
if (environment.containsProperty(enabledProperty)) {
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator audit concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.audit;
import org.jspecify.annotations.NullMarked;
@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.availability;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.availability.LivenessStateHealthIndicator;
import org.springframework.boot.actuate.availability.ReadinessStateHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -99,7 +101,7 @@ public final class AvailabilityProbesAutoConfiguration {
return ConditionOutcome.noMatch(message.because("not running on a supported cloud platform"));
}
private ConditionOutcome onProperty(Environment environment, ConditionMessage.Builder message,
private @Nullable ConditionOutcome onProperty(Environment environment, ConditionMessage.Builder message,
String propertyName) {
String enabled = environment.getProperty(propertyName);
if (enabled != null) {
@@ -20,6 +20,8 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.health.AdditionalHealthEndpointPath;
import org.springframework.boot.actuate.health.HealthEndpointGroup;
@@ -36,9 +38,9 @@ class AvailabilityProbesHealthEndpointGroup implements HealthEndpointGroup {
private final Set<String> members;
private final AdditionalHealthEndpointPath additionalPath;
private final @Nullable AdditionalHealthEndpointPath additionalPath;
AvailabilityProbesHealthEndpointGroup(AdditionalHealthEndpointPath additionalPath, String... members) {
AvailabilityProbesHealthEndpointGroup(@Nullable AdditionalHealthEndpointPath additionalPath, String... members) {
this.members = new HashSet<>(Arrays.asList(members));
this.additionalPath = additionalPath;
}
@@ -69,7 +71,7 @@ class AvailabilityProbesHealthEndpointGroup implements HealthEndpointGroup {
}
@Override
public AdditionalHealthEndpointPath getAdditionalPath() {
public @Nullable AdditionalHealthEndpointPath getAdditionalPath() {
return this.additionalPath;
}
@@ -25,6 +25,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.web.AdditionalPathsMapper;
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
@@ -101,7 +103,7 @@ class AvailabilityProbesHealthEndpointGroups implements HealthEndpointGroups, Ad
}
@Override
public HealthEndpointGroup get(String name) {
public @Nullable HealthEndpointGroup get(String name) {
HealthEndpointGroup group = this.groups.get(name);
if (group == null || isProbeGroup(name)) {
group = this.probeGroups.get(name);
@@ -114,7 +116,7 @@ class AvailabilityProbesHealthEndpointGroups implements HealthEndpointGroups, Ad
}
@Override
public List<String> getAdditionalPaths(EndpointId endpointId, WebServerNamespace webServerNamespace) {
public @Nullable List<String> getAdditionalPaths(EndpointId endpointId, WebServerNamespace webServerNamespace) {
if (!HealthEndpoint.ID.equals(endpointId)) {
return null;
}
@@ -18,4 +18,7 @@
* Auto-configuration that extends health endpoints so that they can be used as
* availability probes.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.availability;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator Spring Bean concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.beans;
import org.jspecify.annotations.NullMarked;
@@ -26,6 +26,7 @@ import java.util.Set;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.OperationResponseBody;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
@@ -71,7 +72,7 @@ public class ConditionsReportEndpoint {
return new ConditionsDescriptor(contextConditionEvaluations);
}
private ConfigurableApplicationContext getConfigurableParent(ConfigurableApplicationContext context) {
private @Nullable ConfigurableApplicationContext getConfigurableParent(ConfigurableApplicationContext context) {
ApplicationContext parent = context.getParent();
if (parent instanceof ConfigurableApplicationContext configurableParent) {
return configurableParent;
@@ -111,7 +112,7 @@ public class ConditionsReportEndpoint {
private final Set<String> unconditionalClasses;
private final String parentId;
private final @Nullable String parentId;
public ContextConditionsDescriptor(ConfigurableApplicationContext context) {
ConditionEvaluationReport report = ConditionEvaluationReport.get(context.getBeanFactory());
@@ -150,7 +151,7 @@ public class ConditionsReportEndpoint {
return this.unconditionalClasses;
}
public String getParentId() {
public @Nullable String getParentId() {
return this.parentId;
}
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator condition concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.condition;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator Spring Context concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.context;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator property concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.context.properties;
import org.jspecify.annotations.NullMarked;
@@ -19,6 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint;
import java.time.Duration;
import java.util.function.Function;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor;
import org.springframework.boot.context.properties.bind.BindResult;
@@ -34,7 +36,7 @@ import org.springframework.core.env.PropertyResolver;
* @author Stephane Nicoll
* @author Phillip Webb
*/
class EndpointIdTimeToLivePropertyFunction implements Function<EndpointId, Long> {
class EndpointIdTimeToLivePropertyFunction implements Function<EndpointId, @Nullable Long> {
private static final Bindable<Duration> DURATION = Bindable.of(Duration.class);
@@ -49,7 +51,7 @@ class EndpointIdTimeToLivePropertyFunction implements Function<EndpointId, Long>
}
@Override
public Long apply(EndpointId endpointId) {
public @Nullable Long apply(EndpointId endpointId) {
String name = String.format("management.endpoint.%s.cache.time-to-live", endpointId.toLowerCaseString());
BindResult<Duration> duration = Binder.get(this.environment).bind(name, DURATION);
return duration.map(Duration::toMillis).orElse(null);
@@ -19,6 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.Access;
import org.springframework.boot.actuate.endpoint.EndpointAccessResolver;
import org.springframework.boot.actuate.endpoint.EndpointId;
@@ -47,7 +49,7 @@ public class PropertiesEndpointAccessResolver implements EndpointAccessResolver
private final PropertyResolver properties;
private final Access endpointsDefaultAccess;
private final @Nullable Access endpointsDefaultAccess;
private final Access maxPermittedAccess;
@@ -60,7 +62,7 @@ public class PropertiesEndpointAccessResolver implements EndpointAccessResolver
Access.UNRESTRICTED);
}
private static Access determineDefaultAccess(PropertyResolver properties) {
private static @Nullable Access determineDefaultAccess(PropertyResolver properties) {
Access defaultAccess = properties.getProperty(DEFAULT_ACCESS_KEY, Access.class);
Boolean endpointsEnabledByDefault = properties.getProperty(ENABLED_BY_DEFAULT_KEY, Boolean.class);
MutuallyExclusiveConfigurationPropertiesException.throwIfMultipleNonNullValuesIn((entries) -> {
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.condition;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
@@ -46,7 +48,7 @@ public interface EndpointExposureOutcomeContributor {
* @return a {@link ConditionOutcome#isMatch() matching} {@link ConditionOutcome} if
* the endpoint is exposed or {@code null} if the contributor should not apply
*/
ConditionOutcome getExposureOutcome(EndpointId endpointId, Set<EndpointExposure> exposures,
@Nullable ConditionOutcome getExposureOutcome(EndpointId endpointId, Set<EndpointExposure> exposures,
ConditionMessage.Builder message);
}
@@ -24,6 +24,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.autoconfigure.endpoint.PropertiesEndpointAccessResolver;
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure;
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.IncludeExcludeEndpointFilter;
@@ -135,7 +137,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
.accessFor(endpointId, defaultAccess);
}
private ConditionOutcome getExposureOutcome(ConditionContext context,
private @Nullable ConditionOutcome getExposureOutcome(ConditionContext context,
MergedAnnotation<ConditionalOnAvailableEndpoint> conditionAnnotation,
MergedAnnotation<Endpoint> endpointAnnotation, EndpointId endpointId, Builder message) {
Set<EndpointExposure> exposures = getExposures(conditionAnnotation);
@@ -170,7 +172,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
return contributors;
}
private List<EndpointExposureOutcomeContributor> loadExposureOutcomeContributors(ClassLoader classLoader,
private List<EndpointExposureOutcomeContributor> loadExposureOutcomeContributors(@Nullable ClassLoader classLoader,
Environment environment) {
ArgumentResolver argumentResolver = ArgumentResolver.of(Environment.class, environment);
return SpringFactoriesLoader.forDefaultResourceLocation(classLoader)
@@ -198,7 +200,7 @@ class OnAvailableEndpointCondition extends SpringBootCondition {
}
@Override
public ConditionOutcome getExposureOutcome(EndpointId endpointId, Set<EndpointExposure> exposures,
public @Nullable ConditionOutcome getExposureOutcome(EndpointId endpointId, Set<EndpointExposure> exposures,
ConditionMessage.Builder message) {
if (exposures.contains(this.exposure) && this.filter.match(endpointId)) {
return ConditionOutcome
@@ -17,4 +17,7 @@
/**
* Actuator endpoint auto-configuration conditions.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint.condition;
import org.jspecify.annotations.NullMarked;
@@ -24,6 +24,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.EndpointFilter;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.ExposableEndpoint;
@@ -149,11 +151,11 @@ public class IncludeExcludeEndpointFilter<E extends ExposableEndpoint<?>> implem
private final Set<EndpointId> endpointIds;
EndpointPatterns(String[] patterns) {
EndpointPatterns(String @Nullable [] patterns) {
this((patterns != null) ? Arrays.asList(patterns) : null);
}
EndpointPatterns(Collection<String> patterns) {
EndpointPatterns(@Nullable Collection<String> patterns) {
patterns = (patterns != null) ? patterns : Collections.emptySet();
boolean matchesAll = false;
Set<EndpointId> endpointIds = new LinkedHashSet<>();
@@ -17,4 +17,7 @@
/**
* Endpoint exposure logic used for auto-configuration and conditions.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint.expose;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Actuator Jackson auto-configuration.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint.jackson;
import org.jspecify.annotations.NullMarked;
@@ -20,10 +20,13 @@ import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.jmx.EndpointObjectNameFactory;
import org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint;
import org.springframework.boot.autoconfigure.jmx.JmxProperties;
import org.springframework.jmx.support.ObjectNameManager;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -39,12 +42,12 @@ class DefaultEndpointObjectNameFactory implements EndpointObjectNameFactory {
private final JmxProperties jmxProperties;
private final MBeanServer mBeanServer;
private final @Nullable MBeanServer mBeanServer;
private final String contextId;
DefaultEndpointObjectNameFactory(JmxEndpointProperties properties, JmxProperties jmxProperties,
MBeanServer mBeanServer, String contextId) {
@Nullable MBeanServer mBeanServer, String contextId) {
this.properties = properties;
this.jmxProperties = jmxProperties;
this.mBeanServer = mBeanServer;
@@ -80,6 +83,7 @@ class DefaultEndpointObjectNameFactory implements EndpointObjectNameFactory {
private boolean hasMBean(String baseObjectName) throws MalformedObjectNameException {
ObjectName query = new ObjectName(baseObjectName + ",*");
Assert.state(this.mBeanServer != null, "'mBeanServer' must not be null");
return !this.mBeanServer.queryNames(query, null).isEmpty();
}
@@ -20,6 +20,8 @@ import java.util.LinkedHashSet;
import java.util.Properties;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -36,7 +38,7 @@ public class JmxEndpointProperties {
/**
* Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set.
*/
private String domain;
private @Nullable String domain;
/**
* Additional static properties to append to all ObjectNames of MBeans representing
@@ -48,11 +50,11 @@ public class JmxEndpointProperties {
return this.exposure;
}
public String getDomain() {
public @Nullable String getDomain() {
return this.domain;
}
public void setDomain(String domain) {
public void setDomain(@Nullable String domain) {
this.domain = domain;
}
@@ -17,4 +17,7 @@
/**
* Actuator JMX endpoint auto-configuration.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint.jmx;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Core classes for actuator endpoint auto-configuration.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint;
import org.jspecify.annotations.NullMarked;
@@ -21,6 +21,8 @@ import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.convert.DurationUnit;
@@ -69,7 +71,7 @@ public class CorsEndpointProperties {
/**
* Whether credentials are supported. When not set, credentials are not supported.
*/
private Boolean allowCredentials;
private @Nullable Boolean allowCredentials;
/**
* How long the response from a pre-flight request can be cached by clients. If a
@@ -118,11 +120,11 @@ public class CorsEndpointProperties {
this.exposedHeaders = exposedHeaders;
}
public Boolean getAllowCredentials() {
public @Nullable Boolean getAllowCredentials() {
return this.allowCredentials;
}
public void setAllowCredentials(Boolean allowCredentials) {
public void setAllowCredentials(@Nullable Boolean allowCredentials) {
this.allowCredentials = allowCredentials;
}
@@ -134,7 +136,7 @@ public class CorsEndpointProperties {
this.maxAge = maxAge;
}
public CorsConfiguration toCorsConfiguration() {
public @Nullable CorsConfiguration toCorsConfiguration() {
if (CollectionUtils.isEmpty(this.allowedOrigins) && CollectionUtils.isEmpty(this.allowedOriginPatterns)) {
return null;
}
@@ -19,6 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web;
import java.util.HashMap;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.EndpointId;
import org.springframework.boot.actuate.endpoint.web.PathMapper;
import org.springframework.core.Ordered;
@@ -42,7 +44,7 @@ class MappingWebEndpointPathMapper implements PathMapper {
}
@Override
public String getRootPath(EndpointId endpointId) {
public @Nullable String getRootPath(EndpointId endpointId) {
String path = this.pathMapping.get(endpointId);
return StringUtils.hasText(path) ? path : null;
}
@@ -17,4 +17,7 @@
/**
* Auto-configuration for the Actuator's web endpoints.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.endpoint.web;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator Spring Environment concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.env;
import org.jspecify.annotations.NullMarked;
@@ -19,6 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.health;
import java.util.Collection;
import java.util.function.Predicate;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.actuate.health.AdditionalHealthEndpointPath;
@@ -41,13 +43,13 @@ class AutoConfiguredHealthEndpointGroup implements HealthEndpointGroup {
private final HttpCodeStatusMapper httpCodeStatusMapper;
private final Show showComponents;
private final @Nullable Show showComponents;
private final Show showDetails;
private final Collection<String> roles;
private final AdditionalHealthEndpointPath additionalPath;
private final @Nullable AdditionalHealthEndpointPath additionalPath;
/**
* Create a new {@link AutoConfiguredHealthEndpointGroup} instance.
@@ -60,8 +62,8 @@ class AutoConfiguredHealthEndpointGroup implements HealthEndpointGroup {
* @param additionalPath the additional path to use for this group
*/
AutoConfiguredHealthEndpointGroup(Predicate<String> members, StatusAggregator statusAggregator,
HttpCodeStatusMapper httpCodeStatusMapper, Show showComponents, Show showDetails, Collection<String> roles,
AdditionalHealthEndpointPath additionalPath) {
HttpCodeStatusMapper httpCodeStatusMapper, @Nullable Show showComponents, Show showDetails,
Collection<String> roles, @Nullable AdditionalHealthEndpointPath additionalPath) {
this.members = members;
this.statusAggregator = statusAggregator;
this.httpCodeStatusMapper = httpCodeStatusMapper;
@@ -98,7 +100,7 @@ class AutoConfiguredHealthEndpointGroup implements HealthEndpointGroup {
}
@Override
public AdditionalHealthEndpointPath getAdditionalPath() {
public @Nullable AdditionalHealthEndpointPath getAdditionalPath() {
return this.additionalPath;
}
@@ -27,6 +27,8 @@ import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory;
@@ -92,7 +94,7 @@ class AutoConfiguredHealthEndpointGroups implements HealthEndpointGroups, Additi
private Map<String, HealthEndpointGroup> createGroups(Map<String, Group> groupProperties, BeanFactory beanFactory,
StatusAggregator defaultStatusAggregator, HttpCodeStatusMapper defaultHttpCodeStatusMapper,
Show defaultShowComponents, Show defaultShowDetails, Set<String> defaultRoles) {
@Nullable Show defaultShowComponents, Show defaultShowDetails, Set<String> defaultRoles) {
Map<String, HealthEndpointGroup> groups = new TreeMap<>();
groupProperties.forEach((groupName, group) -> {
Status status = group.getStatus();
@@ -122,7 +124,7 @@ class AutoConfiguredHealthEndpointGroups implements HealthEndpointGroups, Additi
return Collections.unmodifiableMap(groups);
}
private <T> T getNonQualifiedBean(ListableBeanFactory beanFactory, Class<T> type) {
private <T> @Nullable T getNonQualifiedBean(ListableBeanFactory beanFactory, Class<T> type) {
List<String> candidates = new ArrayList<>();
for (String beanName : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, type)) {
String[] aliases = beanFactory.getAliases(beanName);
@@ -161,12 +163,12 @@ class AutoConfiguredHealthEndpointGroups implements HealthEndpointGroups, Additi
}
@Override
public HealthEndpointGroup get(String name) {
public @Nullable HealthEndpointGroup get(String name) {
return this.groups.get(name);
}
@Override
public List<String> getAdditionalPaths(EndpointId endpointId, WebServerNamespace webServerNamespace) {
public @Nullable List<String> getAdditionalPaths(EndpointId endpointId, WebServerNamespace webServerNamespace) {
if (!HealthEndpoint.ID.equals(endpointId)) {
return null;
}
@@ -19,6 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.health;
import java.util.Collections;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.health.HealthEndpointGroups;
import org.springframework.boot.health.registry.HealthContributorNameValidator;
import org.springframework.util.Assert;
@@ -32,7 +34,7 @@ class GroupsHealthContributorNameValidator implements HealthContributorNameValid
private final Set<String> groupNames;
GroupsHealthContributorNameValidator(HealthEndpointGroups groups) {
GroupsHealthContributorNameValidator(@Nullable HealthEndpointGroups groups) {
this.groupNames = (groups != null) ? groups.getNames() : Collections.emptySet();
}
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.health;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.SmartInitializingSingleton;
@@ -154,7 +156,7 @@ class HealthEndpointConfiguration {
});
}
private void validate(Set<String> names, String type, String group) {
private void validate(@Nullable Set<String> names, String type, String group) {
if (CollectionUtils.isEmpty(names)) {
return;
}
@@ -21,6 +21,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.actuate.health.HealthEndpoint;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -76,18 +78,18 @@ public class HealthEndpointProperties extends HealthProperties {
/**
* Health indicator IDs that should be included or '*' for all.
*/
private Set<String> include;
private @Nullable Set<String> include;
/**
* Health indicator IDs that should be excluded or '*' for all.
*/
private Set<String> exclude;
private @Nullable Set<String> exclude;
/**
* When to show full health details. Defaults to the value of
* 'management.endpoint.health.show-details'.
*/
private Show showDetails;
private @Nullable Show showDetails;
/**
* Additional path that this group can be made available on. The additional path
@@ -95,38 +97,38 @@ public class HealthEndpointProperties extends HealthProperties {
* it will be available on the main port or the management port. For instance,
* `server:/healthz` will configure the group on the main port at `/healthz`.
*/
private String additionalPath;
private @Nullable String additionalPath;
public Set<String> getInclude() {
public @Nullable Set<String> getInclude() {
return this.include;
}
public void setInclude(Set<String> include) {
public void setInclude(@Nullable Set<String> include) {
this.include = include;
}
public Set<String> getExclude() {
public @Nullable Set<String> getExclude() {
return this.exclude;
}
public void setExclude(Set<String> exclude) {
public void setExclude(@Nullable Set<String> exclude) {
this.exclude = exclude;
}
@Override
public Show getShowDetails() {
public @Nullable Show getShowDetails() {
return this.showDetails;
}
public void setShowDetails(Show showDetails) {
public void setShowDetails(@Nullable Show showDetails) {
this.showDetails = showDetails;
}
public String getAdditionalPath() {
public @Nullable String getAdditionalPath() {
return this.additionalPath;
}
public void setAdditionalPath(String additionalPath) {
public void setAdditionalPath(@Nullable String additionalPath) {
this.additionalPath = additionalPath;
}
@@ -23,6 +23,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.endpoint.Show;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.util.CollectionUtils;
@@ -42,7 +44,7 @@ public abstract class HealthProperties {
/**
* When to show components. If not specified the 'show-details' setting will be used.
*/
private Show showComponents;
private @Nullable Show showComponents;
/**
* Roles used to determine whether a user is authorized to be shown details. When
@@ -54,15 +56,15 @@ public abstract class HealthProperties {
return this.status;
}
public Show getShowComponents() {
public @Nullable Show getShowComponents() {
return this.showComponents;
}
public void setShowComponents(Show showComponents) {
public void setShowComponents(@Nullable Show showComponents) {
this.showComponents = showComponents;
}
public abstract Show getShowDetails();
public abstract @Nullable Show getShowDetails();
public Set<String> getRoles() {
return this.roles;
@@ -22,6 +22,10 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Contract;
/**
* Member predicate that matches based on {@code include} and {@code exclude} sets.
*
@@ -34,7 +38,7 @@ class IncludeExcludeGroupMemberPredicate implements Predicate<String> {
private final Set<String> exclude;
IncludeExcludeGroupMemberPredicate(Set<String> include, Set<String> exclude) {
IncludeExcludeGroupMemberPredicate(@Nullable Set<String> include, @Nullable Set<String> exclude) {
this.include = clean(include);
this.exclude = clean(exclude);
}
@@ -75,7 +79,7 @@ class IncludeExcludeGroupMemberPredicate implements Predicate<String> {
return false;
}
private Set<String> clean(Set<String> names) {
private Set<String> clean(@Nullable Set<String> names) {
if (names == null) {
return Collections.emptySet();
}
@@ -83,7 +87,8 @@ class IncludeExcludeGroupMemberPredicate implements Predicate<String> {
return Collections.unmodifiableSet(cleaned);
}
private String clean(String name) {
@Contract("!null -> !null")
private @Nullable String clean(@Nullable String name) {
return (name != null) ? name.trim() : null;
}
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator health concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.health;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator info concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.info;
import org.jspecify.annotations.NullMarked;
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.logging;
import java.io.File;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.actuate.logging.LogFileWebEndpoint;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -34,13 +36,13 @@ public class LogFileWebEndpointProperties {
* External Logfile to be accessed. Can be used if the logfile is written by output
* redirect and not by the logging system itself.
*/
private File externalFile;
private @Nullable File externalFile;
public File getExternalFile() {
public @Nullable File getExternalFile() {
return this.externalFile;
}
public void setExternalFile(File externalFile) {
public void setExternalFile(@Nullable File externalFile) {
this.externalFile = externalFile;
}
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.logging;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@@ -61,8 +63,8 @@ class OnEnabledLoggingExportCondition extends SpringBootCondition {
.because("is enabled by default"));
}
private static String getExporterName(AnnotatedTypeMetadata metadata) {
Map<String, Object> attributes = metadata
private static @Nullable String getExporterName(AnnotatedTypeMetadata metadata) {
Map<String, @Nullable Object> attributes = metadata
.getAnnotationAttributes(ConditionalOnEnabledLoggingExport.class.getName());
if (attributes == null) {
return null;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator logging concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.logging;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator management concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.management;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Classes for general actuator auto-configuration concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator SBOM concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.sbom;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator scheduling concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.scheduling;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator ssl concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.ssl;
import org.jspecify.annotations.NullMarked;
@@ -16,6 +16,7 @@
package org.springframework.boot.actuate.autoconfigure.startup;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
import org.springframework.boot.actuate.startup.StartupEndpoint;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -30,6 +31,7 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
import org.springframework.core.metrics.ApplicationStartup;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.Assert;
/**
* {@link EnableAutoConfiguration Auto-configuration} for the {@link StartupEndpoint}.
@@ -60,7 +62,9 @@ public final class StartupEndpointAutoConfiguration {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition("ApplicationStartup");
ApplicationStartup applicationStartup = context.getBeanFactory().getApplicationStartup();
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
Assert.state(beanFactory != null, "'beanFactory' must not be null");
ApplicationStartup applicationStartup = beanFactory.getApplicationStartup();
if (applicationStartup instanceof BufferingApplicationStartup) {
return ConditionOutcome
.match(message.because("configured applicationStartup is of type BufferingApplicationStartup."));
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator ApplicationStartup concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.startup;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator system concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.system;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Auto-configuration for actuator HTTP exchanges.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.web.exchanges;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Classes for auto-configuration of actuator web request mapping concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.web.mappings;
import org.jspecify.annotations.NullMarked;
@@ -17,4 +17,7 @@
/**
* Core classes for auto-configuration of actuator web concerns.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.web;
import org.jspecify.annotations.NullMarked;
@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.web.server;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.core.Ordered;
@@ -31,13 +33,13 @@ import org.springframework.core.Ordered;
public abstract class AccessLogCustomizer<T extends WebServerFactory>
implements WebServerFactoryCustomizer<T>, Ordered {
private final String prefix;
private final @Nullable String prefix;
protected AccessLogCustomizer(String prefix) {
protected AccessLogCustomizer(@Nullable String prefix) {
this.prefix = prefix;
}
protected String customizePrefix(String existingPrefix) {
protected @Nullable String customizePrefix(@Nullable String existingPrefix) {
if (this.prefix == null) {
return existingPrefix;
}
@@ -20,6 +20,8 @@ import java.util.List;
import javax.lang.model.element.Modifier;
import org.jspecify.annotations.Nullable;
import org.springframework.aot.generate.GeneratedMethod;
import org.springframework.aot.generate.GenerationContext;
import org.springframework.beans.factory.BeanFactory;
@@ -60,9 +62,9 @@ class ChildManagementContextInitializer implements BeanRegistrationAotProcessor,
private final AbstractApplicationContext parentContext;
private final ApplicationContextInitializer<ConfigurableApplicationContext> applicationContextInitializer;
private final @Nullable ApplicationContextInitializer<ConfigurableApplicationContext> applicationContextInitializer;
private volatile ConfigurableApplicationContext managementContext;
private volatile @Nullable ConfigurableApplicationContext managementContext;
ChildManagementContextInitializer(ManagementContextFactory managementContextFactory,
AbstractApplicationContext parentContext) {
@@ -72,7 +74,7 @@ class ChildManagementContextInitializer implements BeanRegistrationAotProcessor,
@SuppressWarnings("unchecked")
private ChildManagementContextInitializer(ManagementContextFactory managementContextFactory,
AbstractApplicationContext parentContext,
ApplicationContextInitializer<? extends ConfigurableApplicationContext> applicationContextInitializer) {
@Nullable ApplicationContextInitializer<? extends ConfigurableApplicationContext> applicationContextInitializer) {
this.managementContextFactory = managementContextFactory;
this.parentContext = parentContext;
this.applicationContextInitializer = (ApplicationContextInitializer<ConfigurableApplicationContext>) applicationContextInitializer;
@@ -117,7 +119,7 @@ class ChildManagementContextInitializer implements BeanRegistrationAotProcessor,
}
@Override
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
public @Nullable BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
Assert.isInstanceOf(ConfigurableApplicationContext.class, this.parentContext);
BeanFactory parentBeanFactory = ((ConfigurableApplicationContext) this.parentContext).getBeanFactory();
if (registeredBean.getBeanClass().equals(getClass())
@@ -231,7 +233,7 @@ class ChildManagementContextInitializer implements BeanRegistrationAotProcessor,
propagateCloseIfNecessary(event.getApplicationContext());
}
private void propagateCloseIfNecessary(ApplicationContext applicationContext) {
private void propagateCloseIfNecessary(@Nullable ApplicationContext applicationContext) {
if (applicationContext == this.parentContext) {
this.childContext.close();
}
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.web.server;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -134,13 +136,13 @@ public final class ManagementContextAutoConfiguration {
}
@Override
public Object getProperty(String name) {
public @Nullable Object getProperty(String name) {
String mapped = PROPERTY_MAPPINGS.get(name);
return (mapped != null) ? this.environment.getProperty(mapped) : null;
}
@Override
public Origin getOrigin(String key) {
public @Nullable Origin getOrigin(String key) {
return null;
}
@@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
@@ -32,6 +34,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
@@ -50,13 +53,14 @@ import org.springframework.util.StringUtils;
@Order(Ordered.LOWEST_PRECEDENCE)
class ManagementContextConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware {
private ClassLoader classLoader;
private @Nullable ClassLoader classLoader;
@Override
public String[] selectImports(AnnotationMetadata metadata) {
ManagementContextType contextType = (ManagementContextType) metadata
.getAnnotationAttributes(EnableManagementContext.class.getName())
.get("value");
Map<String, @Nullable Object> attributes = metadata
.getAnnotationAttributes(EnableManagementContext.class.getName());
Assert.state(attributes != null, "'attributes' must not be null");
ManagementContextType contextType = (ManagementContextType) attributes.get("value");
// Find all management context configuration classes, filtering duplicates
List<ManagementConfiguration> configurations = getConfigurations();
OrderComparator.sort(configurations);
@@ -118,14 +122,19 @@ class ManagementContextConfigurationImportSelector implements DeferredImportSele
}
private ManagementContextType readContextType(AnnotationMetadata annotationMetadata) {
Map<String, Object> annotationAttributes = annotationMetadata
Map<String, @Nullable Object> annotationAttributes = annotationMetadata
.getAnnotationAttributes(ManagementContextConfiguration.class.getName());
return (annotationAttributes != null) ? (ManagementContextType) annotationAttributes.get("value")
: ManagementContextType.ANY;
if (annotationAttributes == null) {
return ManagementContextType.ANY;
}
ManagementContextType value = (ManagementContextType) annotationAttributes.get("value");
Assert.state(value != null, "'value' must not be null");
return value;
}
private int readOrder(AnnotationMetadata annotationMetadata) {
Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(Order.class.getName());
Map<String, @Nullable Object> attributes = annotationMetadata
.getAnnotationAttributes(Order.class.getName());
Integer order = (attributes != null) ? (Integer) attributes.get("value") : null;
return (order != null) ? order : Ordered.LOWEST_PRECEDENCE;
}
@@ -30,6 +30,7 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigRegistry;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
/**
* Factory for creating a separate management context when the management web server is
@@ -60,6 +61,7 @@ public final class ManagementContextFactory {
Environment parentEnvironment = parentContext.getEnvironment();
ConfigurableEnvironment childEnvironment = ApplicationContextFactory.DEFAULT
.createEnvironment(this.webApplicationType);
Assert.state(childEnvironment != null, "'childEnvironment' must not be null");
if (parentEnvironment instanceof ConfigurableEnvironment configurableEnvironment) {
childEnvironment.setConversionService((configurableEnvironment).getConversionService());
}
@@ -16,6 +16,8 @@
package org.springframework.boot.actuate.autoconfigure.web.server;
import org.jspecify.annotations.Nullable;
import org.springframework.core.env.Environment;
/**
@@ -60,7 +62,7 @@ public enum ManagementPortType {
|| (managementPort != 0 && managementPort.equals(serverPort))) ? SAME : DIFFERENT);
}
private static Integer getPortProperty(Environment environment, String prefix) {
private static @Nullable Integer getPortProperty(Environment environment, String prefix) {
return environment.getProperty(prefix + "port", Integer.class);
}
@@ -18,10 +18,13 @@ package org.springframework.boot.actuate.autoconfigure.web.server;
import java.net.InetAddress;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
import org.springframework.lang.Contract;
import org.springframework.util.StringUtils;
/**
@@ -41,13 +44,13 @@ public class ManagementServerProperties {
* Management endpoint HTTP port (uses the same port as the application by default).
* Configure a different port to use management-specific SSL.
*/
private Integer port;
private @Nullable Integer port;
/**
* Network address to which the management endpoints should bind. Requires a custom
* management.server.port.
*/
private InetAddress address;
private @Nullable InetAddress address;
/**
* Management endpoint base path (for instance, '/management'). Requires a custom
@@ -56,7 +59,7 @@ public class ManagementServerProperties {
private String basePath = "";
@NestedConfigurationProperty
private Ssl ssl;
private @Nullable Ssl ssl;
/**
* Returns the management port or {@code null} if the
@@ -64,7 +67,7 @@ public class ManagementServerProperties {
* @return the port
* @see #setPort(Integer)
*/
public Integer getPort() {
public @Nullable Integer getPort() {
return this.port;
}
@@ -74,15 +77,15 @@ public class ManagementServerProperties {
* random port or set to -1 to disable.
* @param port the port
*/
public void setPort(Integer port) {
public void setPort(@Nullable Integer port) {
this.port = port;
}
public InetAddress getAddress() {
public @Nullable InetAddress getAddress() {
return this.address;
}
public void setAddress(InetAddress address) {
public void setAddress(@Nullable InetAddress address) {
this.address = address;
}
@@ -94,15 +97,16 @@ public class ManagementServerProperties {
this.basePath = cleanBasePath(basePath);
}
public Ssl getSsl() {
public @Nullable Ssl getSsl() {
return this.ssl;
}
public void setSsl(Ssl ssl) {
public void setSsl(@Nullable Ssl ssl) {
this.ssl = ssl;
}
private String cleanBasePath(String basePath) {
@Contract("!null -> !null")
private @Nullable String cleanBasePath(@Nullable String basePath) {
String candidate = null;
if (StringUtils.hasLength(basePath)) {
candidate = basePath.strip();
@@ -20,6 +20,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -30,6 +32,7 @@ import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
/**
* {@link WebServerFactoryCustomizer} that customizes the {@link WebServerFactory} used to
@@ -44,7 +47,7 @@ public class ManagementWebServerFactoryCustomizer<T extends ConfigurableWebServe
private final ListableBeanFactory beanFactory;
private final Class<? extends WebServerFactoryCustomizer<?>>[] customizerClasses;
private final Class<? extends WebServerFactoryCustomizer<?>> @Nullable [] customizerClasses;
/**
* Creates a new customizer that will retrieve beans using the given
@@ -81,6 +84,7 @@ public class ManagementWebServerFactoryCustomizer<T extends ConfigurableWebServe
private void customizeSameAsParentContext(T factory) {
List<WebServerFactoryCustomizer<?>> customizers = new ArrayList<>();
Assert.state(this.customizerClasses != null, "'customizerClasses' must not be null");
for (Class<? extends WebServerFactoryCustomizer<?>> customizerClass : this.customizerClasses) {
try {
customizers.add(BeanFactoryUtils.beanOfTypeIncludingAncestors(this.beanFactory, customizerClass));
@@ -100,7 +104,9 @@ public class ManagementWebServerFactoryCustomizer<T extends ConfigurableWebServe
protected void customize(T factory, ManagementServerProperties managementServerProperties,
ServerProperties serverProperties) {
factory.setPort(managementServerProperties.getPort());
Integer port = managementServerProperties.getPort();
Assert.state(port != null, "'port' must not be null");
factory.setPort(port);
Ssl ssl = managementServerProperties.getSsl();
if (ssl != null) {
factory.setSsl(ssl);
@@ -18,6 +18,8 @@ package org.springframework.boot.actuate.autoconfigure.web.server;
import java.util.Map;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@@ -25,6 +27,7 @@ import org.springframework.boot.web.context.reactive.ConfigurableReactiveWebAppl
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.web.context.WebApplicationContext;
@@ -44,7 +47,9 @@ class OnManagementPortCondition extends SpringBootCondition {
if (!isWebApplicationContext(context)) {
return ConditionOutcome.noMatch(message.because("non web application context"));
}
Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnManagementPort.class.getName());
Map<String, @Nullable Object> attributes = metadata
.getAnnotationAttributes(ConditionalOnManagementPort.class.getName());
Assert.state(attributes != null, "'attributes' must not be null");
ManagementPortType requiredType = (ManagementPortType) attributes.get("value");
ManagementPortType actualType = ManagementPortType.get(context.getEnvironment());
if (actualType == requiredType) {
@@ -17,4 +17,7 @@
/**
* Actuator web server support.
*/
@NullMarked
package org.springframework.boot.actuate.autoconfigure.web.server;
import org.jspecify.annotations.NullMarked;