Skip to content

Commit e1dc6f5

Browse files
committed
Add nullability support
This reviews the entire code base to explicitly declare APIs that accept and/or return a null value. The code base is validated using ErrorProne. Closes gh-1562
2 parents d370dbd + 06eaa1d commit e1dc6f5

File tree

358 files changed

+1895
-1097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

358 files changed

+1895
-1097
lines changed

gradle/plugins/conventions-plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies {
1515
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}")
1616

1717
implementation("com.github.ben-manes:gradle-versions-plugin:$gradleVersionsPluginVersion")
18+
implementation("io.spring.gradle.nullability:nullability-plugin:$nullabilityPluginVersion")
1819
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:$javaFormatVersion")
1920

2021
testImplementation("org.junit.jupiter:junit-jupiter")

gradle/plugins/conventions-plugin/src/main/java/org/springframework/ws/gradle/conventions/ConventionsPlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.ws.gradle.conventions;
1818

19+
import io.spring.gradle.nullability.NullabilityPlugin;
1920
import org.gradle.api.Plugin;
2021
import org.gradle.api.Project;
2122
import org.gradle.api.plugins.JavaBasePlugin;
@@ -37,7 +38,10 @@ public void apply(Project project) {
3738
new JavaBasePluginConventions().apply(project);
3839
new CheckstyleConventions().apply(project);
3940
});
40-
project.getPlugins().withType(JavaPlugin.class).all((plugin) -> new JavaPluginConventions().apply(project));
41+
project.getPlugins().withType(JavaPlugin.class).all((plugin) -> {
42+
project.getPlugins().apply(NullabilityPlugin.class);
43+
new JavaPluginConventions().apply(project);
44+
});
4145
project.getPlugins()
4246
.withType(MavenPublishPlugin.class)
4347
.all((plugin) -> new MavenPublishPluginConventions().apply(project));

gradle/plugins/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
assertJVersion=3.25.3
22
gradleVersionsPluginVersion=0.52.0
3-
javaFormatVersion=0.0.45
3+
javaFormatVersion=0.0.46
44
junitVersion=5.11.0
5+
nullabilityPluginVersion=0.0.1

spring-ws-core/src/main/java/org/springframework/ws/FaultAwareWebServiceMessage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import javax.xml.namespace.QName;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
/**
2224
* Sub-interface of {@link WebServiceMessage} that can contain special Fault messages.
2325
* Fault messages (such as {@link org.springframework.ws.soap.SoapFault} SOAP Faults)
@@ -39,14 +41,14 @@ public interface FaultAwareWebServiceMessage extends WebServiceMessage {
3941
/**
4042
* Returns the fault code, if any.
4143
*/
42-
QName getFaultCode();
44+
@Nullable QName getFaultCode();
4345

4446
/**
4547
* Returns the fault reason message.
4648
* @return the fault reason message, if any; returns {@code null} when no fault is
4749
* present.
4850
* @see #hasFault()
4951
*/
50-
String getFaultReason();
52+
@Nullable String getFaultReason();
5153

5254
}

spring-ws-core/src/main/java/org/springframework/ws/WebServiceException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.ws;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.core.NestedRuntimeException;
2022

2123
/**
@@ -31,7 +33,7 @@ public abstract class WebServiceException extends NestedRuntimeException {
3133
* Create a new instance of the {@code WebServiceException} class.
3234
* @param msg the detail message
3335
*/
34-
public WebServiceException(String msg) {
36+
public WebServiceException(@Nullable String msg) {
3537
super(msg);
3638
}
3739

@@ -40,7 +42,7 @@ public WebServiceException(String msg) {
4042
* @param msg the detail message
4143
* @param ex the root {@link Throwable exception}
4244
*/
43-
public WebServiceException(String msg, Throwable ex) {
45+
public WebServiceException(@Nullable String msg, Throwable ex) {
4446
super(msg, ex);
4547
}
4648

spring-ws-core/src/main/java/org/springframework/ws/WebServiceMessage.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import javax.xml.transform.Result;
2323
import javax.xml.transform.Source;
2424

25+
import org.jspecify.annotations.Nullable;
26+
2527
/**
2628
* Represents a protocol-agnostic XML message.
2729
* <p>
@@ -41,7 +43,7 @@ public interface WebServiceMessage {
4143
* single time.
4244
* @return the message contents
4345
*/
44-
Source getPayloadSource();
46+
@Nullable Source getPayloadSource();
4547

4648
/**
4749
* Returns the contents of the message as a {@link Result}.

spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceClientException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.ws.client;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.ws.WebServiceException;
2022

2123
/**
@@ -31,7 +33,7 @@ public abstract class WebServiceClientException extends WebServiceException {
3133
* Create a new instance of the {@code WebServiceClientException} class.
3234
* @param msg the detail message
3335
*/
34-
public WebServiceClientException(String msg) {
36+
public WebServiceClientException(@Nullable String msg) {
3537
super(msg);
3638
}
3739

spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceFaultException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.ws.client;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.ws.FaultAwareWebServiceMessage;
2022

2123
/**
@@ -27,7 +29,7 @@
2729
@SuppressWarnings("serial")
2830
public class WebServiceFaultException extends WebServiceClientException {
2931

30-
private final FaultAwareWebServiceMessage faultMessage;
32+
private final @Nullable FaultAwareWebServiceMessage faultMessage;
3133

3234
/** Create a new instance of the {@code WebServiceFaultException} class. */
3335
public WebServiceFaultException(String msg) {
@@ -45,7 +47,7 @@ public WebServiceFaultException(FaultAwareWebServiceMessage faultMessage) {
4547
}
4648

4749
/** Returns the fault message. */
48-
public FaultAwareWebServiceMessage getWebServiceMessage() {
50+
public @Nullable FaultAwareWebServiceMessage getWebServiceMessage() {
4951
return this.faultMessage;
5052
}
5153

spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceIOException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.io.IOException;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
/**
2224
* Exception thrown whenever an I/O error occurs on the client-side.
2325
*
@@ -31,7 +33,7 @@ public class WebServiceIOException extends WebServiceClientException {
3133
* Create a new instance of the {@code WebServiceIOException} class.
3234
* @param msg the detail message
3335
*/
34-
public WebServiceIOException(String msg) {
36+
public WebServiceIOException(@Nullable String msg) {
3537
super(msg);
3638
}
3739

spring-ws-core/src/main/java/org/springframework/ws/client/WebServiceTransportException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.ws.client;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import org.springframework.ws.transport.TransportException;
2022

2123
/**
@@ -31,7 +33,7 @@ public class WebServiceTransportException extends WebServiceIOException {
3133
* Create a new instance of the {@code WebServiceTransportException} class.
3234
* @param msg the detail message
3335
*/
34-
public WebServiceTransportException(String msg) {
36+
public WebServiceTransportException(@Nullable String msg) {
3537
super(msg);
3638
}
3739

0 commit comments

Comments
 (0)