Skip to content

Commit 7f3fa88

Browse files
committed
Upgrade to ErrorProne 2.45.0 and NullAway 0.12.14
This change also sets `RequireExplicitNullMarking` to ERROR level and annotates all the missing packages. Signed-off-by: Stefano Cordio <[email protected]>
1 parent 98c10cd commit 7f3fa88

37 files changed

+366
-52
lines changed

pom.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@
146146
<maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
147147
<maven-jar-plugin.version>3.5.0</maven-jar-plugin.version>
148148
<spring-javaformat-maven-plugin.version>0.0.47</spring-javaformat-maven-plugin.version>
149-
<error-prone.version>2.44.0</error-prone.version>
150-
<nullaway.version>0.12.12</nullaway.version>
149+
<error-prone.version>2.45.0</error-prone.version>
150+
<nullaway.version>0.12.14</nullaway.version>
151151
</properties>
152152

153153
<build>
@@ -180,9 +180,10 @@
180180
<compilerArg>
181181
-Xplugin:ErrorProne
182182
<!-- Check JSpecify annotations -->
183+
-Xep:RequireExplicitNullMarking:ERROR
183184
-Xep:NullAway:ERROR
184-
-XepOpt:NullAway:JSpecifyMode=true
185-
-XepOpt:NullAway:OnlyNullMarked
185+
-XepOpt:NullAway:JSpecifyMode=true
186+
-XepOpt:NullAway:OnlyNullMarked
186187
-XepOpt:NullAway:SuppressionNameAliases=DataFlowIssue
187188
<!-- https://github.com/uber/NullAway/issues/162 -->
188189
-XepExcludedPaths:.*/src/test/java/.*

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
*
44
* @author Michael Minella
55
*/
6-
package org.springframework.batch.core.annotation;
6+
@NullMarked
7+
package org.springframework.batch.core.annotation;
8+
9+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/aot/CoreRuntimeHints.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.util.concurrent.locks.ReentrantLock;
4545
import java.util.stream.Stream;
4646

47+
import org.jspecify.annotations.Nullable;
4748
import org.springframework.aop.SpringProxy;
4849
import org.springframework.aop.framework.Advised;
4950
import org.springframework.aot.hint.ExecutableMode;
@@ -91,7 +92,7 @@
9192
public class CoreRuntimeHints implements RuntimeHintsRegistrar {
9293

9394
@Override
94-
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
95+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
9596

9697
Set<String> jdkTypes = Set.of("java.time.Ser", "java.util.Collections$SynchronizedSet",
9798
"java.util.Collections$SynchronizedCollection", "java.util.concurrent.locks.ReentrantLock$Sync",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Core implementations of Spring AOT concerns.
19+
*
20+
* @author Stefano Cordio
21+
*/
22+
@NullMarked
23+
package org.springframework.batch.core.aot;
24+
25+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/job/parameters/CompositeJobParametersValidator.java

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

18+
import java.util.Collections;
1819
import java.util.List;
1920

2021
import org.jspecify.annotations.Nullable;
@@ -27,11 +28,11 @@
2728
*
2829
* @author Morten Andersen-Gott
2930
* @author Mahmoud Ben Hassine
30-
*
31+
* @author Stefano Cordio
3132
*/
3233
public class CompositeJobParametersValidator implements JobParametersValidator, InitializingBean {
3334

34-
private List<JobParametersValidator> validators;
35+
private List<JobParametersValidator> validators = Collections.emptyList();
3536

3637
/**
3738
* Validates the JobParameters according to the injected JobParameterValidators
@@ -57,7 +58,6 @@ public void setValidators(List<JobParametersValidator> validators) {
5758

5859
@Override
5960
public void afterPropertiesSet() throws Exception {
60-
Assert.state(validators != null, "The 'validators' may not be null");
6161
Assert.state(!validators.isEmpty(), "The 'validators' may not be empty");
6262
}
6363

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Job parameter concerns.
3+
*
4+
* @author Stefano Cordio
5+
*/
6+
@NullMarked
7+
package org.springframework.batch.core.job.parameters;
8+
9+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/TaskExecutorJobOperator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public JobExecution start(Job job, JobParameters jobParameters) throws JobInstan
110110
Assert.notNull(job, "Job must not be null");
111111
Assert.notNull(jobParameters, "JobParameters must not be null");
112112
new JobLaunchEvent(job.getName(), jobParameters.toString()).commit();
113+
114+
@SuppressWarnings("DataFlowIssue")
113115
Observation observation = MicrometerMetrics
114116
.createObservation(METRICS_PREFIX + "job.launch.count", this.observationRegistry)
115117
.start();

spring-batch-core/src/main/java/org/springframework/batch/core/observability/jfr/events/job/JobExecutionEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import jdk.jfr.Description;
2020
import jdk.jfr.Event;
2121
import jdk.jfr.Label;
22+
import org.jspecify.annotations.Nullable;
2223

2324
@Label("Job Execution")
2425
@Description("Job Execution Event")
@@ -35,7 +36,7 @@ public class JobExecutionEvent extends Event {
3536
public long jobExecutionId;
3637

3738
@Label("Job Exit Status")
38-
public String exitStatus;
39+
public @Nullable String exitStatus;
3940

4041
public JobExecutionEvent(String jobName, long jobInstanceId, long jobExecutionId) {
4142
this.jobName = jobName;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2022-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/**
18+
* Job related JFR events.
19+
*/
20+
@NullMarked
21+
package org.springframework.batch.core.observability.jfr.events.job;
22+
23+
import org.jspecify.annotations.NullMarked;

spring-batch-core/src/main/java/org/springframework/batch/core/observability/jfr/events/step/StepExecutionEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import jdk.jfr.Description;
2020
import jdk.jfr.Event;
2121
import jdk.jfr.Label;
22+
import org.jspecify.annotations.Nullable;
2223

2324
@Label("Step Execution")
2425
@Description("Step Execution Event")
@@ -38,7 +39,7 @@ public class StepExecutionEvent extends Event {
3839
public long jobExecutionId;
3940

4041
@Label("Step Exit Status")
41-
public String exitStatus;
42+
public @Nullable String exitStatus;
4243

4344
public StepExecutionEvent(String stepName, String jobName, long stepExecutionId, long jobExecutionId) {
4445
this.stepName = stepName;

0 commit comments

Comments
 (0)