Skip to content

Commit abeb820

Browse files
committed
Fix NullAway findings
Signed-off-by: Stefano Cordio <stefano.cordio@gmail.com>
1 parent 140e0af commit abeb820

File tree

70 files changed

+364
-288
lines changed

Some content is hidden

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

70 files changed

+364
-288
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
<!-- Check JSpecify annotations -->
192192
-Xep:NullAway:ERROR
193193
-XepOpt:NullAway:OnlyNullMarked
194+
-XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract
194195
</compilerArg>
195196
</compilerArgs>
196197
<annotationProcessorPaths>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private Collection<Job> doLoad(ApplicationContextFactory factory, boolean unregi
222222
* @return all the {@link Step} defined by the given step locator and context
223223
* @see StepLocator
224224
*/
225-
private Collection<Step> getSteps(final StepLocator stepLocator, final ApplicationContext jobApplicationContext) {
225+
private Collection<Step> getSteps(StepLocator stepLocator, final ApplicationContext jobApplicationContext) {
226226
final Collection<String> stepNames = stepLocator.getStepNames();
227227
final Collection<Step> result = new ArrayList<>();
228228
for (String stepName : stepNames) {

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Collection<String> getStepNames() {
127127
* @see AbstractJob#doExecute(JobExecution)
128128
*/
129129
@Override
130-
protected void doExecute(final JobExecution execution) throws JobExecutionException {
130+
protected void doExecute(JobExecution execution) throws JobExecutionException {
131131
try {
132132
JobFlowExecutor executor = new JobFlowExecutor(getJobRepository(),
133133
new SimpleStepHandler(getJobRepository()), execution);

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/SplitState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ public Collection<Flow> getFlows() {
9797
* @see State#handle(FlowExecutor)
9898
*/
9999
@Override
100-
public FlowExecutionStatus handle(final FlowExecutor executor) throws Exception {
100+
public FlowExecutionStatus handle(FlowExecutor executor) throws Exception {
101101

102102
// TODO: collect the last StepExecution from the flows as well, so they
103103
// can be abandoned if necessary
104104
Collection<Future<FlowExecution>> tasks = new ArrayList<>();
105105

106-
for (final Flow flow : flows) {
106+
for (Flow flow : flows) {
107107

108108
final FutureTask<FlowExecution> task = new FutureTask<>(() -> flow.start(executor));
109109

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ public class TaskExecutorJobLauncher implements JobLauncher, InitializingBean {
9898
* @throws JobParametersInvalidException thrown if jobParameters is invalid.
9999
*/
100100
@Override
101-
public JobExecution run(final Job job, final JobParameters jobParameters)
102-
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
103-
JobParametersInvalidException {
101+
public JobExecution run(Job job, final JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
102+
JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException {
104103

105104
Assert.notNull(job, "The Job must not be null.");
106105
Assert.notNull(jobParameters, "The JobParameters must not be null.");

spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/AbstractPartitionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected abstract Set<StepExecution> doHandle(StepExecution managerStepExecutio
5252
* @see PartitionHandler#handle(StepExecutionSplitter, StepExecution)
5353
*/
5454
@Override
55-
public Collection<StepExecution> handle(final StepExecutionSplitter stepSplitter,
55+
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter,
5656
final StepExecution managerStepExecution) throws Exception {
5757
final Set<StepExecution> stepExecutions = stepSplitter.split(managerStepExecution, gridSize);
5858

spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/TaskExecutorPartitionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected Set<StepExecution> doHandle(StepExecution managerStepExecution,
9393
final Set<Future<StepExecution>> tasks = new HashSet<>(getGridSize());
9494
final Set<StepExecution> result = new HashSet<>();
9595

96-
for (final StepExecution stepExecution : partitionStepExecutions) {
96+
for (StepExecution stepExecution : partitionStepExecutions) {
9797
final FutureTask<StepExecution> task = createTask(step, stepExecution);
9898

9999
try {
@@ -127,7 +127,7 @@ protected Set<StepExecution> doHandle(StepExecution managerStepExecution,
127127
* @param stepExecution the given execution
128128
* @return the task executing the given step
129129
*/
130-
protected FutureTask<StepExecution> createTask(final Step step, final StepExecution stepExecution) {
130+
protected FutureTask<StepExecution> createTask(Step step, final StepExecution stepExecution) {
131131
return new FutureTask<>(() -> {
132132
step.execute(stepExecution);
133133
return stepExecution;

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/ExecutionContextDao.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,36 @@ public interface ExecutionContextDao {
4848
* entry for the context should not exist yet.
4949
* @param jobExecution {@link JobExecution} instance that contains the context.
5050
*/
51-
void saveExecutionContext(final JobExecution jobExecution);
51+
void saveExecutionContext(JobExecution jobExecution);
5252

5353
/**
5454
* Persist the execution context associated with the given stepExecution, persistent
5555
* entry for the context should not exist yet.
5656
* @param stepExecution {@link StepExecution} instance that contains the context.
5757
*/
58-
void saveExecutionContext(final StepExecution stepExecution);
58+
void saveExecutionContext(StepExecution stepExecution);
5959

6060
/**
6161
* Persist the execution context associated with each stepExecution in a given
6262
* collection, persistent entry for the context should not exist yet.
6363
* @param stepExecutions a collection of {@link StepExecution}s that contain the
6464
* contexts.
6565
*/
66-
void saveExecutionContexts(final Collection<StepExecution> stepExecutions);
66+
void saveExecutionContexts(Collection<StepExecution> stepExecutions);
6767

6868
/**
6969
* Persist the updates of execution context associated with the given jobExecution.
7070
* Persistent entry should already exist for this context.
7171
* @param jobExecution {@link JobExecution} instance that contains the context.
7272
*/
73-
void updateExecutionContext(final JobExecution jobExecution);
73+
void updateExecutionContext(JobExecution jobExecution);
7474

7575
/**
7676
* Persist the updates of execution context associated with the given stepExecution.
7777
* Persistent entry should already exist for this context.
7878
* @param stepExecution {@link StepExecution} instance that contains the context.
7979
*/
80-
void updateExecutionContext(final StepExecution stepExecution);
80+
void updateExecutionContext(StepExecution stepExecution);
8181

8282
/**
8383
* Delete the execution context of the given {@link JobExecution}.

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcExecutionContextDao.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public ExecutionContext getExecutionContext(StepExecution stepExecution) {
172172
}
173173

174174
@Override
175-
public void updateExecutionContext(final JobExecution jobExecution) {
175+
public void updateExecutionContext(JobExecution jobExecution) {
176176
Long executionId = jobExecution.getId();
177177
ExecutionContext executionContext = jobExecution.getExecutionContext();
178178
Assert.notNull(executionId, "ExecutionId must not be null.");
@@ -184,7 +184,7 @@ public void updateExecutionContext(final JobExecution jobExecution) {
184184
}
185185

186186
@Override
187-
public void updateExecutionContext(final StepExecution stepExecution) {
187+
public void updateExecutionContext(StepExecution stepExecution) {
188188
// Attempt to prevent concurrent modification errors by blocking here if
189189
// someone is already trying to do it.
190190
this.lock.lock();
@@ -271,7 +271,7 @@ public void afterPropertiesSet() throws Exception {
271271
* @param serializedContext the serialized context to persist
272272
* @param sql with parameters (shortContext, longContext, executionId)
273273
*/
274-
private void persistSerializedContext(final Long executionId, String serializedContext, String sql) {
274+
private void persistSerializedContext(Long executionId, String serializedContext, String sql) {
275275

276276
final String shortContext;
277277
final String longContext;
@@ -302,7 +302,7 @@ private void persistSerializedContext(final Long executionId, String serializedC
302302
* @param serializedContexts the execution contexts to serialize
303303
* @param sql with parameters (shortContext, longContext, executionId)
304304
*/
305-
private void persistSerializedContexts(final Map<Long, String> serializedContexts, String sql) {
305+
private void persistSerializedContexts(Map<Long, String> serializedContexts, String sql) {
306306
if (!serializedContexts.isEmpty()) {
307307
final Iterator<Long> executionIdIterator = serializedContexts.keySet().iterator();
308308

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcJobExecutionDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void afterPropertiesSet() throws Exception {
207207
}
208208

209209
@Override
210-
public List<JobExecution> findJobExecutions(final JobInstance job) {
210+
public List<JobExecution> findJobExecutions(JobInstance job) {
211211

212212
Assert.notNull(job, "Job cannot be null.");
213213
Assert.notNull(job.getId(), "Job Id cannot be null.");

0 commit comments

Comments
 (0)