Skip to content

Commit 113d9e6

Browse files
committed
Use JSpecify for nullability constraints
Resolves #192 Signed-off-by: onobc <[email protected]>
1 parent 9e98730 commit 113d9e6

File tree

14 files changed

+68
-11
lines changed

14 files changed

+68
-11
lines changed

pom.xml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<spring-asciidoctor-backends.version>0.0.6</spring-asciidoctor-backends.version>
9696

9797
<!-- plugin versions -->
98-
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
98+
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
9999
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
100100
<maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version>
101101
<maven-flatten-plugin.version>1.6.0</maven-flatten-plugin.version>
@@ -111,6 +111,9 @@
111111
<maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
112112
<maven-project-info-reports-plugin.version>3.4.5</maven-project-info-reports-plugin.version>
113113
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
114+
<!-- Nullability plugins -->
115+
<error-prone.version>2.44.0</error-prone.version>
116+
<nullaway.version>0.12.12</nullaway.version>
114117
<!-- BEGIN format + checkstyle properties -->
115118
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
116119
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
@@ -193,9 +196,39 @@
193196
<version>${maven-compiler-plugin.version}</version>
194197
<configuration>
195198
<release>${java.version}</release>
199+
<showWarnings>true</showWarnings>
196200
<compilerArgs>
197201
<compilerArg>-parameters</compilerArg>
202+
<compilerArg>-Xdoclint:none</compilerArg>
203+
<compilerArg>-Werror</compilerArg>
204+
<compilerArg>-XDcompilePolicy=simple</compilerArg>
205+
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
206+
<compilerArg>
207+
-Xplugin:ErrorProne
208+
<!-- Disable all built-in error prone checks -->
209+
-XepDisableAllChecks
210+
<!-- JSpecify mode https://github.com/uber/NullAway/wiki/JSpecify-Support -->
211+
-XepOpt:NullAway:JSpecifyMode=true
212+
<!-- Check JSpecify annotations -->
213+
-Xep:NullAway:ERROR
214+
-XepOpt:NullAway:OnlyNullMarked
215+
-XepOpt:NullAway:TreatGeneratedAsUnannotated=true
216+
<!-- https://github.com/uber/NullAway/issues/162 -->
217+
-XepExcludedPaths:.*/src/test/java/.*
218+
</compilerArg>
198219
</compilerArgs>
220+
<annotationProcessorPaths>
221+
<path>
222+
<groupId>com.google.errorprone</groupId>
223+
<artifactId>error_prone_core</artifactId>
224+
<version>${error-prone.version}</version>
225+
</path>
226+
<path>
227+
<groupId>com.uber.nullaway</groupId>
228+
<artifactId>nullaway</artifactId>
229+
<version>${nullaway.version}</version>
230+
</path>
231+
</annotationProcessorPaths>
199232
</configuration>
200233
</plugin>
201234
<plugin>

spring-grpc-build-dependencies/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
</licenses>
5050

5151
<properties>
52+
<jspecify.version>1.0.0</jspecify.version>
5253
<spring-framework.version>7.0.1</spring-framework.version>
5354
<spring-security.version>7.0.0</spring-security.version>
5455
<micrometer.version>1.16.0</micrometer.version>
@@ -94,6 +95,11 @@
9495
<type>pom</type>
9596
<scope>import</scope>
9697
</dependency>
98+
<dependency>
99+
<groupId>org.jspecify</groupId>
100+
<artifactId>jspecify</artifactId>
101+
<version>${jspecify.version}</version>
102+
</dependency>
97103
</dependencies>
98104
</dependencyManagement>
99105

spring-grpc-core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<artifactId>spring-security-web</artifactId>
2424
<optional>true</optional>
2525
</dependency>
26+
<dependency>
27+
<groupId>org.jspecify</groupId>
28+
<artifactId>jspecify</artifactId>
29+
</dependency>
2630
<dependency>
2731
<groupId>io.grpc</groupId>
2832
<artifactId>grpc-core</artifactId>

spring-grpc-core/src/main/java/org/springframework/grpc/client/DefaultGrpcChannelFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
import java.util.List;
2323
import java.util.concurrent.TimeUnit;
2424

25+
import org.jspecify.annotations.Nullable;
26+
2527
import org.springframework.beans.factory.DisposableBean;
2628
import org.springframework.core.log.LogAccessor;
27-
import org.springframework.lang.Nullable;
2829
import org.springframework.util.Assert;
2930

3031
import io.grpc.ChannelCredentials;

spring-grpc-core/src/main/java/org/springframework/grpc/client/aot/ClientBeanRegistrationsAotProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import java.util.HashSet;
2424
import java.util.Set;
2525

26+
import org.jspecify.annotations.Nullable;
27+
2628
import org.springframework.aot.generate.GenerationContext;
2729
import org.springframework.aot.hint.MemberCategory;
2830
import org.springframework.aot.hint.ReflectionHints;
@@ -36,7 +38,6 @@
3638
import org.springframework.beans.factory.support.RegisteredBean;
3739
import org.springframework.core.MethodParameter;
3840
import org.springframework.grpc.client.GrpcClientFactory;
39-
import org.springframework.lang.Nullable;
4041
import org.springframework.util.ClassUtils;
4142
import org.springframework.util.ReflectionUtils;
4243

spring-grpc-core/src/main/java/org/springframework/grpc/package-info.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
/**
18+
* Core module for Spring gRPC.
19+
*/
20+
@NullMarked
1721
package org.springframework.grpc;
22+
23+
import org.jspecify.annotations.NullMarked;

spring-grpc-core/src/main/java/org/springframework/grpc/server/DefaultGrpcServerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727

2828
import org.apache.commons.logging.Log;
2929
import org.apache.commons.logging.LogFactory;
30+
import org.jspecify.annotations.Nullable;
3031

3132
import org.springframework.grpc.internal.GrpcUtils;
3233
import org.springframework.grpc.server.service.ServerInterceptorFilter;
33-
import org.springframework.lang.Nullable;
3434

3535
import io.grpc.Grpc;
3636
import io.grpc.InsecureServerCredentials;

spring-grpc-core/src/main/java/org/springframework/grpc/server/security/SslContextPreAuthenticationExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
import javax.net.ssl.SSLSession;
2525

26-
import org.springframework.lang.Nullable;
26+
import org.jspecify.annotations.Nullable;
27+
2728
import org.springframework.security.core.Authentication;
2829
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
2930
import org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor;

spring-grpc-core/src/main/java/org/springframework/grpc/server/service/DefaultGrpcServiceConfigurer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import java.util.Arrays;
2121
import java.util.List;
2222

23+
import org.jspecify.annotations.Nullable;
24+
2325
import org.springframework.beans.factory.InitializingBean;
2426
import org.springframework.context.ApplicationContext;
2527
import org.springframework.grpc.internal.ApplicationContextBeanLookupUtils;
2628
import org.springframework.grpc.server.GlobalServerInterceptor;
2729
import org.springframework.grpc.server.GrpcServerFactory;
28-
import org.springframework.lang.Nullable;
2930
import org.springframework.util.Assert;
3031

3132
import io.grpc.BindableService;

spring-grpc-core/src/main/java/org/springframework/grpc/server/service/DefaultGrpcServiceDiscoverer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
import java.util.List;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.context.ApplicationContext;
2224
import org.springframework.grpc.internal.ApplicationContextBeanLookupUtils;
23-
import org.springframework.lang.Nullable;
2425

2526
import io.grpc.BindableService;
2627
import io.grpc.ServerServiceDefinition;

0 commit comments

Comments
 (0)