Skip to content

Commit a7092a2

Browse files
mikeldplfmbenhassine
authored andcommitted
Added @nullable annotation to overriding methods.
Resolves BATCH-2839
1 parent 4ec227c commit a7092a2

File tree

199 files changed

+726
-259
lines changed

Some content is hidden

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

199 files changed

+726
-259
lines changed

spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingItemProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,13 @@
1616
package org.springframework.batch.core.test.timeout;
1717

1818
import org.springframework.batch.item.ItemProcessor;
19+
import org.springframework.lang.Nullable;
1920

2021
public class SleepingItemProcessor<I> implements ItemProcessor<I, I> {
2122

2223
private long millisToSleep;
2324

25+
@Nullable
2426
@Override
2527
public I process(I item) throws Exception {
2628
Thread.sleep(millisToSleep);

spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingTasklet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,11 +19,13 @@
1919
import org.springframework.batch.core.scope.context.ChunkContext;
2020
import org.springframework.batch.core.step.tasklet.Tasklet;
2121
import org.springframework.batch.repeat.RepeatStatus;
22+
import org.springframework.lang.Nullable;
2223

2324
public class SleepingTasklet implements Tasklet {
2425

2526
private long millisToSleep;
2627

28+
@Nullable
2729
@Override
2830
public RepeatStatus execute(StepContribution contribution,
2931
ChunkContext chunkContext) throws Exception {

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@
5353
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseConfigurer;
5454
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory;
5555
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
56+
import org.springframework.lang.Nullable;
5657
import org.springframework.test.annotation.DirtiesContext;
5758
import org.springframework.test.context.ContextConfiguration;
5859
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -154,13 +155,15 @@ public Flow flow() {
154155
return new FlowBuilder<Flow>("flow")
155156
.start(stepBuilderFactory.get("flow.step1")
156157
.tasklet(new Tasklet() {
158+
@Nullable
157159
@Override
158160
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
159161
return RepeatStatus.FINISHED;
160162
}
161163
}).build()
162164
).next(stepBuilderFactory.get("flow.step2")
163165
.tasklet(new Tasklet() {
166+
@Nullable
164167
@Override
165168
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
166169
return RepeatStatus.FINISHED;
@@ -173,6 +176,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
173176
public Step firstStep() {
174177
return stepBuilderFactory.get("firstStep")
175178
.tasklet(new Tasklet() {
179+
@Nullable
176180
@Override
177181
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
178182
System.out.println(">> Beginning concurrent job test");
@@ -185,6 +189,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
185189
public Step lastStep() {
186190
return stepBuilderFactory.get("lastStep")
187191
.tasklet(new Tasklet() {
192+
@Nullable
188193
@Override
189194
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
190195
System.out.println(">> Ending concurrent job test");

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/MyMapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2005-2014 the original author or authors.
2+
* Copyright 2005-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616
package org.springframework.batch.core.test.ldif;
1717

1818
import org.springframework.batch.item.ldif.RecordMapper;
19+
import org.springframework.lang.Nullable;
1920
import org.springframework.ldap.core.LdapAttributes;
2021

2122
/**
@@ -28,8 +29,9 @@
2829
*/
2930
public class MyMapper implements RecordMapper<LdapAttributes> {
3031

32+
@Nullable
3133
public LdapAttributes mapRecord(LdapAttributes attributes) {
3234
return attributes;
3335
}
3436

35-
}
37+
}

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/builder/MappingLdifReaderBuilderTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 the original author or authors.
2+
* Copyright 2017-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import org.springframework.beans.factory.annotation.Autowired;
3030
import org.springframework.context.ApplicationContext;
3131
import org.springframework.context.annotation.Configuration;
32+
import org.springframework.lang.Nullable;
3233
import org.springframework.ldap.core.LdapAttributes;
3334
import org.springframework.test.context.junit4.SpringRunner;
3435

@@ -210,6 +211,7 @@ public void handleRecord(LdapAttributes attributes) {
210211
}
211212

212213
public class TestMapper implements RecordMapper<LdapAttributes> {
214+
@Nullable
213215
@Override
214216
public LdapAttributes mapRecord(LdapAttributes attributes) {
215217
return attributes;

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2007 the original author or authors.
2+
* Copyright 2006-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import org.springframework.batch.core.UnexpectedJobExecutionException;
2828
import org.springframework.batch.core.job.DefaultJobParametersValidator;
2929
import org.springframework.beans.factory.BeanNameAware;
30+
import org.springframework.lang.Nullable;
3031
import org.springframework.util.ClassUtils;
3132

3233
/**
@@ -149,6 +150,7 @@ public boolean isRestartable() {
149150
/* (non-Javadoc)
150151
* @see org.springframework.batch.core.Job#getJobParametersIncrementer()
151152
*/
153+
@Nullable
152154
@Override
153155
public JobParametersIncrementer getJobParametersIncrementer() {
154156
return null;

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanIntegrationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2014 the original author or authors.
2+
* Copyright 2010-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
import org.springframework.beans.factory.annotation.Autowired;
4949
import org.springframework.jdbc.core.JdbcTemplate;
5050
import org.springframework.jdbc.core.RowMapper;
51+
import org.springframework.lang.Nullable;
5152
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
5253
import org.springframework.test.context.ContextConfiguration;
5354
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -189,6 +190,7 @@ public void clear() {
189190
counter = -1;
190191
}
191192

193+
@Nullable
192194
@Override
193195
public synchronized String read() throws Exception, UnexpectedInputException, ParseException {
194196
counter++;
@@ -273,6 +275,7 @@ public void clear() {
273275
jdbcTemplate.update("DELETE FROM ERROR_LOG where STEP_NAME='processed'");
274276
}
275277

278+
@Nullable
276279
@Override
277280
public String process(String item) throws Exception {
278281
processed.add(item);

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanRollbackIntegrationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2014 the original author or authors.
2+
* Copyright 2010-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
import org.springframework.beans.factory.annotation.Autowired;
4949
import org.springframework.jdbc.core.JdbcTemplate;
5050
import org.springframework.jdbc.core.RowMapper;
51+
import org.springframework.lang.Nullable;
5152
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
5253
import org.springframework.test.context.ContextConfiguration;
5354
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -210,6 +211,7 @@ public void clear() {
210211
counter = -1;
211212
}
212213

214+
@Nullable
213215
@Override
214216
public synchronized String read() throws Exception, UnexpectedInputException, ParseException {
215217
counter++;
@@ -305,6 +307,7 @@ public void clear() {
305307
jdbcTemplate.update("DELETE FROM ERROR_LOG where STEP_NAME='processed'");
306308
}
307309

310+
@Nullable
308311
@Override
309312
public String process(String item) throws Exception {
310313
processed.add(item);

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepIntegrationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.batch.item.ItemWriter;
2525
import org.springframework.batch.item.support.ListItemReader;
2626
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.lang.Nullable;
2728
import org.springframework.test.context.ContextConfiguration;
2829
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
2930
import org.springframework.transaction.PlatformTransactionManager;
@@ -152,6 +153,7 @@ public void testExceptionInProcessDuringChunkScan() throws Exception {
152153
ItemProcessor<Integer, Integer> itemProcessor = new ItemProcessor<Integer, Integer>() {
153154
private int cpt;
154155

156+
@Nullable
155157
@Override
156158
public Integer process(Integer item) throws Exception {
157159
cpt++;

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanRollbackTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2014 the original author or authors.
2+
* Copyright 2010-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@
4141
import org.springframework.batch.item.ItemReader;
4242
import org.springframework.batch.item.ItemWriter;
4343
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
44+
import org.springframework.lang.Nullable;
4445
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
4546
import org.springframework.transaction.PlatformTransactionManager;
4647
import org.springframework.util.Assert;
@@ -176,6 +177,7 @@ public void clear() {
176177
counter = -1;
177178
}
178179

180+
@Nullable
179181
@Override
180182
public synchronized String read() throws Exception {
181183
counter++;
@@ -236,6 +238,7 @@ public void clear() {
236238
processed.clear();
237239
}
238240

241+
@Nullable
239242
@Override
240243
public String process(String item) throws Exception {
241244
processed.add(item);

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2014 the original author or authors.
2+
* Copyright 2010-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@
4242
import org.springframework.batch.item.ParseException;
4343
import org.springframework.batch.item.UnexpectedInputException;
4444
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
45+
import org.springframework.lang.Nullable;
4546
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
4647
import org.springframework.transaction.PlatformTransactionManager;
4748
import org.springframework.util.Assert;
@@ -172,6 +173,7 @@ public void clear() {
172173
counter = -1;
173174
}
174175

176+
@Nullable
175177
@Override
176178
public synchronized String read() throws Exception, UnexpectedInputException, ParseException {
177179
counter++;
@@ -226,6 +228,7 @@ public void clear() {
226228
processed.clear();
227229
}
228230

231+
@Nullable
229232
@Override
230233
public String process(String item) throws Exception {
231234
processed.add(item);

spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2009 the original author or authors.
2+
* Copyright 2006-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
import org.springframework.batch.core.step.tasklet.Tasklet;
3434
import org.springframework.batch.repeat.RepeatStatus;
3535
import org.springframework.context.support.ClassPathXmlApplicationContext;
36+
import org.springframework.lang.Nullable;
3637

3738
/**
3839
* @author Dave Syer
@@ -87,6 +88,7 @@ public static class CountingTasklet implements Tasklet {
8788

8889
private AtomicInteger count = new AtomicInteger(0);
8990

91+
@Nullable
9092
@Override
9193
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
9294
contribution.incrementReadCount();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import org.springframework.batch.core.configuration.JobFactory;
2626
import org.springframework.batch.core.configuration.JobRegistry;
2727
import org.springframework.batch.core.launch.NoSuchJobException;
28+
import org.springframework.lang.Nullable;
2829
import org.springframework.util.Assert;
2930

3031
/**
@@ -61,7 +62,7 @@ public void unregister(String name) {
6162
}
6263

6364
@Override
64-
public Job getJob(String name) throws NoSuchJobException {
65+
public Job getJob(@Nullable String name) throws NoSuchJobException {
6566
JobFactory factory = map.get(name);
6667
if (factory == null) {
6768
throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered");

spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public JobExecution getLastJobExecution(JobInstance jobInstance) {
110110
* (java.lang.String)
111111
*/
112112
@Override
113-
public Set<JobExecution> findRunningJobExecutions(String jobName) {
113+
public Set<JobExecution> findRunningJobExecutions(@Nullable String jobName) {
114114
Set<JobExecution> executions = jobExecutionDao.findRunningJobExecutions(jobName);
115115
for (JobExecution jobExecution : executions) {
116116
getJobExecutionDependencies(jobExecution);
@@ -128,8 +128,9 @@ public Set<JobExecution> findRunningJobExecutions(String jobName) {
128128
* org.springframework.batch.core.explore.JobExplorer#getJobExecution(java
129129
* .lang.Long)
130130
*/
131+
@Nullable
131132
@Override
132-
public JobExecution getJobExecution(Long executionId) {
133+
public JobExecution getJobExecution(@Nullable Long executionId) {
133134
if (executionId == null) {
134135
return null;
135136
}
@@ -151,8 +152,9 @@ public JobExecution getJobExecution(Long executionId) {
151152
* org.springframework.batch.core.explore.JobExplorer#getStepExecution(java
152153
* .lang.Long)
153154
*/
155+
@Nullable
154156
@Override
155-
public StepExecution getStepExecution(Long jobExecutionId, Long executionId) {
157+
public StepExecution getStepExecution(@Nullable Long jobExecutionId, @Nullable Long executionId) {
156158
JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
157159
if (jobExecution == null) {
158160
return null;
@@ -170,6 +172,7 @@ public StepExecution getStepExecution(Long jobExecutionId, Long executionId) {
170172
* org.springframework.batch.core.explore.JobExplorer#getJobInstance(java
171173
* .lang.Long)
172174
*/
175+
@Nullable
173176
@Override
174177
public JobInstance getJobInstance(@Nullable Long instanceId) {
175178
return jobInstanceDao.getJobInstance(instanceId);
@@ -182,6 +185,7 @@ public JobInstance getJobInstance(@Nullable Long instanceId) {
182185
* org.springframework.batch.core.explore.JobExplorer#getLastJobInstance(java
183186
* .lang.String)
184187
*/
188+
@Nullable
185189
@Override
186190
public JobInstance getLastJobInstance(String jobName) {
187191
return jobInstanceDao.getLastJobInstance(jobName);

0 commit comments

Comments
 (0)