Browse Source

Upgrade to Nullability Plugin 0.0.11

In addition to the upgrade, this commit also fixes some contract
violations in non-public APIs that are now detected as the new
version of the plugin enables contract checking by default.

Closes gh-49000
4.0.x
Andy Wilkinson 1 week ago
parent
commit
cbfbe59581
  1. 2
      gradle.properties
  2. 6
      module/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java
  3. 7
      module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/context/SpringBootTestRandomPortContextCustomizer.java

2
gradle.properties

@ -19,7 +19,7 @@ kotlinVersion=2.2.21 @@ -19,7 +19,7 @@ kotlinVersion=2.2.21
mavenVersion=3.9.10
mockitoVersion=5.20.0
nativeBuildToolsVersion=0.11.4
nullabilityPluginVersion=0.0.10
nullabilityPluginVersion=0.0.11
snakeYamlVersion=2.5
springFrameworkVersion=7.0.3
springFramework60xVersion=6.0.23

6
module/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java

@ -107,10 +107,10 @@ public class ManagementServerProperties { @@ -107,10 +107,10 @@ public class ManagementServerProperties {
@Contract("!null -> !null")
private @Nullable String cleanBasePath(@Nullable String basePath) {
String candidate = null;
if (StringUtils.hasLength(basePath)) {
candidate = basePath.strip();
if (basePath == null) {
return null;
}
String candidate = basePath.strip();
if (StringUtils.hasText(candidate)) {
if (!candidate.startsWith("/")) {
candidate = "/" + candidate;

7
module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/context/SpringBootTestRandomPortContextCustomizer.java

@ -111,7 +111,7 @@ class SpringBootTestRandomPortContextCustomizer implements ContextCustomizer { @@ -111,7 +111,7 @@ class SpringBootTestRandomPortContextCustomizer implements ContextCustomizer {
private static final Integer ZERO = Integer.valueOf(0);
boolean isFixed(MapPropertySource source, Port port) {
return !ZERO.equals(get(source, port, null));
return !ZERO.equals(get(source, port));
}
boolean isConfigured(PropertySource<?> source, Port port) {
@ -121,14 +121,13 @@ class SpringBootTestRandomPortContextCustomizer implements ContextCustomizer { @@ -121,14 +121,13 @@ class SpringBootTestRandomPortContextCustomizer implements ContextCustomizer {
@Contract("_, _, !null -> !null")
@Nullable Integer get(PropertySources sources, Port port, @Nullable Integer defaultValue) {
return sources.stream()
.map((source) -> get(source, port, defaultValue))
.map((source) -> get(source, port))
.filter(Objects::nonNull)
.findFirst()
.orElse(defaultValue);
}
@Contract("_, _, !null -> !null")
@Nullable Integer get(PropertySource<?> source, Port port, @Nullable Integer defaultValue) {
@Nullable Integer get(PropertySource<?> source, Port port) {
Object value = source.getProperty(port.property());
if (value == null || ClassUtils.isAssignableValue(Integer.class, value)) {
return (Integer) value;

Loading…
Cancel
Save