Skip to content

Commit 0fc1a40

Browse files
committed
Polish nullability annotations
See gh-46926
1 parent 2e8428b commit 0fc1a40

File tree

9 files changed

+21
-15
lines changed

9 files changed

+21
-15
lines changed

core/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void applyToSystemProperties(Runnable action) {
186186
* @param call the call to make
187187
* @return the result of the call
188188
*/
189-
public <T> T applyToSystemProperties(Callable<T> call) {
189+
public <T extends @Nullable Object> T applyToSystemProperties(Callable<T> call) {
190190
try (SystemPropertiesHandler handler = new SystemPropertiesHandler()) {
191191
return call.call();
192192
}

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBean.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ public class EndpointMBean implements DynamicMBean {
5555

5656
private final JmxOperationResponseMapper responseMapper;
5757

58-
private final ClassLoader classLoader;
58+
private final @Nullable ClassLoader classLoader;
5959

6060
private final ExposableJmxEndpoint endpoint;
6161

6262
private final MBeanInfo info;
6363

6464
private final Map<String, JmxOperation> operations;
6565

66-
EndpointMBean(JmxOperationResponseMapper responseMapper, ClassLoader classLoader, ExposableJmxEndpoint endpoint) {
66+
EndpointMBean(JmxOperationResponseMapper responseMapper, @Nullable ClassLoader classLoader,
67+
ExposableJmxEndpoint endpoint) {
6768
Assert.notNull(responseMapper, "'responseMapper' must not be null");
6869
Assert.notNull(endpoint, "'endpoint' must not be null");
6970
this.responseMapper = responseMapper;

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import tools.jackson.databind.JavaType;
2525
import tools.jackson.databind.ObjectMapper;
2626

27+
import org.springframework.lang.Contract;
28+
2729
/**
2830
* {@link JmxOperationResponseMapper} that delegates to a Jackson {@link ObjectMapper} to
2931
* return a JSON response.
@@ -58,6 +60,7 @@ public Class<?> mapResponseType(Class<?> responseType) {
5860
}
5961

6062
@Override
63+
@Contract("!null -> !null")
6164
public @Nullable Object mapResponse(@Nullable Object response) {
6265
if (response == null) {
6366
return null;

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
6565

6666
private final EndpointAccessResolver endpointAccessResolver;
6767

68-
public ServletEndpointRegistrar(String basePath, Collection<ExposableServletEndpoint> servletEndpoints) {
68+
public ServletEndpointRegistrar(@Nullable String basePath, Collection<ExposableServletEndpoint> servletEndpoints) {
6969
this(basePath, servletEndpoints, (endpointId, defaultAccess) -> Access.NONE);
7070
}
7171

72-
public ServletEndpointRegistrar(String basePath, Collection<ExposableServletEndpoint> servletEndpoints,
72+
public ServletEndpointRegistrar(@Nullable String basePath, Collection<ExposableServletEndpoint> servletEndpoints,
7373
EndpointAccessResolver endpointAccessResolver) {
7474
Assert.notNull(servletEndpoints, "'servletEndpoints' must not be null");
7575
this.basePath = cleanBasePath(basePath);

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@
5353
public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableControllerEndpoint, Operation>
5454
implements ControllerEndpointsSupplier {
5555

56-
private final List<PathMapper> endpointPathMappers;
56+
private final @Nullable List<PathMapper> endpointPathMappers;
5757

5858
/**
5959
* Create a new {@link ControllerEndpointDiscoverer} instance.
6060
* @param applicationContext the source application context
6161
* @param endpointPathMappers the endpoint path mappers
6262
* @param filters filters to apply
6363
*/
64-
public ControllerEndpointDiscoverer(ApplicationContext applicationContext, List<PathMapper> endpointPathMappers,
64+
public ControllerEndpointDiscoverer(ApplicationContext applicationContext,
65+
@Nullable List<PathMapper> endpointPathMappers,
6566
Collection<EndpointFilter<ExposableControllerEndpoint>> filters) {
6667
super(applicationContext, ParameterValueMapper.NONE, Collections.emptyList(), filters, Collections.emptyList());
6768
this.endpointPathMappers = endpointPathMappers;

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscoverer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@
5353
public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServletEndpoint, Operation>
5454
implements ServletEndpointsSupplier {
5555

56-
private final List<PathMapper> endpointPathMappers;
56+
private final @Nullable List<PathMapper> endpointPathMappers;
5757

5858
/**
5959
* Create a new {@link ServletEndpointDiscoverer} instance.
6060
* @param applicationContext the source application context
6161
* @param endpointPathMappers the endpoint path mappers
6262
* @param filters filters to apply
6363
*/
64-
public ServletEndpointDiscoverer(ApplicationContext applicationContext, List<PathMapper> endpointPathMappers,
64+
public ServletEndpointDiscoverer(ApplicationContext applicationContext,
65+
@Nullable List<PathMapper> endpointPathMappers,
6566
Collection<EndpointFilter<ExposableServletEndpoint>> filters) {
6667
super(applicationContext, ParameterValueMapper.NONE, Collections.emptyList(), filters, Collections.emptyList());
6768
this.endpointPathMappers = endpointPathMappers;

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class HealthEndpoint extends HealthEndpointSupport<Health, HealthDescript
6262
*/
6363
public HealthEndpoint(HealthContributorRegistry registry,
6464
@Nullable ReactiveHealthContributorRegistry fallbackRegistry, HealthEndpointGroups groups,
65-
Duration slowContributorLoggingThreshold) {
65+
@Nullable Duration slowContributorLoggingThreshold) {
6666
super(Contributor.blocking(registry, fallbackRegistry), groups, slowContributorLoggingThreshold);
6767
}
6868

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public ReactiveHealthEndpointWebExtension(ReactiveHealthContributorRegistry regi
6969

7070
@ReadOperation
7171
public Mono<WebEndpointResponse<? extends HealthDescriptor>> health(ApiVersion apiVersion,
72-
WebServerNamespace serverNamespace, SecurityContext securityContext) {
72+
@Nullable WebServerNamespace serverNamespace, SecurityContext securityContext) {
7373
return health(apiVersion, serverNamespace, securityContext, false, EMPTY_PATH);
7474
}
7575

7676
@ReadOperation
7777
public Mono<WebEndpointResponse<? extends HealthDescriptor>> health(ApiVersion apiVersion,
78-
WebServerNamespace serverNamespace, SecurityContext securityContext,
78+
@Nullable WebServerNamespace serverNamespace, SecurityContext securityContext,
7979
@Selector(match = Match.ALL_REMAINING) String... path) {
8080
return health(apiVersion, serverNamespace, securityContext, false, path);
8181
}

module/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SystemHealthDescriptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
*/
3535
public final class SystemHealthDescriptor extends CompositeHealthDescriptor {
3636

37-
private final Set<String> groups;
37+
private final @Nullable Set<String> groups;
3838

3939
SystemHealthDescriptor(ApiVersion apiVersion, Status status, @Nullable Map<String, HealthDescriptor> components,
40-
Set<String> groups) {
40+
@Nullable Set<String> groups) {
4141
super(apiVersion, status, components);
4242
this.groups = groups;
4343
}
4444

4545
@JsonInclude(Include.NON_EMPTY)
46-
public Set<String> getGroups() {
46+
public @Nullable Set<String> getGroups() {
4747
return this.groups;
4848
}
4949

0 commit comments

Comments
 (0)