Skip to content

Commit 551e26d

Browse files
scordiofmbenhassine
authored andcommitted
Migrate nullability annotations to JSpecify
Signed-off-by: Stefano Cordio <[email protected]> Issue #4673
1 parent 76e723e commit 551e26d

File tree

466 files changed

+2541
-2174
lines changed

Some content is hidden

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

466 files changed

+2541
-2174
lines changed

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
149149
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
150150
<spring-javaformat-maven-plugin.version>0.0.47</spring-javaformat-maven-plugin.version>
151-
<error-prone.version>2.41.0</error-prone.version>
151+
<error-prone.version>2.42.0</error-prone.version>
152+
<nullaway.version>0.12.10</nullaway.version>
152153
</properties>
153154

154155
<build>
@@ -180,6 +181,14 @@
180181
<compilerArg>--should-stop=ifError=FLOW</compilerArg>
181182
<compilerArg>
182183
-Xplugin:ErrorProne
184+
<!-- Check JSpecify annotations -->
185+
-Xep:NullAway:ERROR
186+
-XepOpt:NullAway:OnlyNullMarked
187+
<!-- FIXME Remove once https://github.com/uber/NullAway/pull/1295 is released -->
188+
-XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract
189+
-XepOpt:NullAway:SuppressionNameAliases=DataFlowIssue
190+
<!-- https://github.com/uber/NullAway/issues/162 -->
191+
-XepExcludedPaths:.*/src/test/java/.*
183192
</compilerArg>
184193
</compilerArgs>
185194
<annotationProcessorPaths>
@@ -188,6 +197,11 @@
188197
<artifactId>error_prone_core</artifactId>
189198
<version>${error-prone.version}</version>
190199
</path>
200+
<path>
201+
<groupId>com.uber.nullaway</groupId>
202+
<artifactId>nullaway</artifactId>
203+
<version>${nullaway.version}</version>
204+
</path>
191205
</annotationProcessorPaths>
192206
</configuration>
193207
</plugin>

spring-batch-core/src/main/java/org/springframework/batch/core/SpringBatchVersion.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.batch.core;
1717

18-
import org.springframework.lang.Nullable;
18+
import org.jspecify.annotations.Nullable;
1919

2020
/**
2121
* Class that exposes the Spring Batch version. Fetches the "Implementation-Version"
@@ -43,8 +43,7 @@ private SpringBatchVersion() {
4343
* {@code "N/A"} if it cannot be determined.
4444
* @see Package#getImplementationVersion()
4545
*/
46-
@Nullable
47-
public static String getVersion() {
46+
public static @Nullable String getVersion() {
4847
Package pkg = SpringBatchVersion.class.getPackage();
4948
if (pkg != null && pkg.getImplementationVersion() != null) {
5049
return pkg.getImplementationVersion();

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/package-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Michael Minella
55
* @author Mahmoud Ben Hassine
66
*/
7-
@NonNullApi
7+
@NullMarked
88
package org.springframework.batch.core.configuration.annotation;
99

10-
import org.springframework.lang.NonNullApi;
10+
import org.jspecify.annotations.NullMarked;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Michael Minella
55
* @author Mahmoud Ben Hassine
66
*/
7-
@NonNullApi
7+
@NullMarked
88
package org.springframework.batch.core.configuration;
99

10-
import org.springframework.lang.NonNullApi;
10+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/GroupAwareJob.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616
package org.springframework.batch.core.configuration.support;
1717

18+
import org.jspecify.annotations.Nullable;
19+
1820
import org.springframework.batch.core.job.Job;
1921
import org.springframework.batch.core.job.JobExecution;
2022
import org.springframework.batch.core.job.parameters.JobParametersIncrementer;
2123
import org.springframework.batch.core.job.parameters.JobParametersValidator;
22-
import org.springframework.lang.Nullable;
2324
import org.springframework.util.ClassUtils;
2425

2526
/**
@@ -87,8 +88,7 @@ public boolean isRestartable() {
8788
}
8889

8990
@Override
90-
@Nullable
91-
public JobParametersIncrementer getJobParametersIncrementer() {
91+
public @Nullable JobParametersIncrementer getJobParametersIncrementer() {
9292
return delegate.getJobParametersIncrementer();
9393
}
9494

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java

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

2424
import org.apache.commons.logging.Log;
2525
import org.apache.commons.logging.LogFactory;
26+
import org.jspecify.annotations.Nullable;
27+
2628
import org.springframework.batch.core.job.Job;
2729
import org.springframework.batch.core.configuration.DuplicateJobException;
2830
import org.springframework.batch.core.configuration.JobRegistry;
@@ -31,7 +33,6 @@
3133
import org.springframework.beans.factory.SmartInitializingSingleton;
3234
import org.springframework.context.ApplicationContext;
3335
import org.springframework.context.ApplicationContextAware;
34-
import org.springframework.lang.Nullable;
3536
import org.springframework.util.Assert;
3637

3738
/**

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapStepRegistry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.concurrent.ConcurrentMap;
2323

2424
import org.springframework.batch.core.step.Step;
25+
26+
import org.jspecify.annotations.Nullable;
2527
import org.springframework.batch.core.configuration.DuplicateJobException;
2628
import org.springframework.batch.core.configuration.StepRegistry;
2729
import org.springframework.batch.core.launch.NoSuchJobException;
@@ -62,7 +64,7 @@ public void unregisterStepsFromJob(String jobName) {
6264
}
6365

6466
@Override
65-
public Step getStep(String jobName, String stepName) throws NoSuchJobException {
67+
public @Nullable Step getStep(String jobName, String stepName) throws NoSuchJobException {
6668
Assert.notNull(jobName, "The job name cannot be null.");
6769
Assert.notNull(stepName, "The step name cannot be null.");
6870
if (!map.containsKey(jobName)) {

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/package-info.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @author Michael Minella
55
* @author Mahmoud Ben Hassine
66
*/
7-
@NonNullApi
7+
@NullMarked
88
package org.springframework.batch.core.configuration.support;
99

10-
import org.springframework.lang.NonNullApi;
10+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/ExceptionElementParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import org.springframework.beans.factory.support.ManagedMap;
2323
import org.springframework.beans.factory.xml.ParserContext;
2424
import org.springframework.util.xml.DomUtils;
25+
26+
import org.jspecify.annotations.Nullable;
2527
import org.w3c.dom.Element;
2628

2729
public class ExceptionElementParser {
2830

29-
public ManagedMap<TypedStringValue, Boolean> parse(Element element, ParserContext parserContext,
31+
public @Nullable ManagedMap<TypedStringValue, Boolean> parse(Element element, ParserContext parserContext,
3032
String exceptionListName) {
3133
List<Element> children = DomUtils.getChildElementsByTagName(element, exceptionListName);
3234
if (children.size() == 1) {

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/xml/JobParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.springframework.beans.factory.xml.ParserContext;
3131
import org.springframework.util.StringUtils;
3232
import org.springframework.util.xml.DomUtils;
33+
34+
import org.jspecify.annotations.Nullable;
3335
import org.w3c.dom.Element;
3436

3537
/**
@@ -158,7 +160,7 @@ else if (listenersElements.size() > 1) {
158160
* @param parserContext The {@link ParserContext}.
159161
* @return the {@link BeanMetadataElement} extracted from the element parameter.
160162
*/
161-
public BeanMetadataElement parseBeanElement(Element element, ParserContext parserContext) {
163+
public @Nullable BeanMetadataElement parseBeanElement(Element element, ParserContext parserContext) {
162164
String refAttribute = element.getAttribute(REF_ATTR);
163165
Element beanElement = DomUtils.getChildElementByTagName(element, BEAN_ELE);
164166
Element refElement = DomUtils.getChildElementByTagName(element, REF_ELE);

0 commit comments

Comments
 (0)