diff --git a/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingItemProcessor.java b/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingItemProcessor.java index 0010350051..f0d955deae 100644 --- a/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingItemProcessor.java +++ b/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingItemProcessor.java @@ -16,11 +16,13 @@ package org.springframework.batch.core.test.timeout; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; public class SleepingItemProcessor implements ItemProcessor { private long millisToSleep; + @Nullable @Override public I process(I item) throws Exception { Thread.sleep(millisToSleep); diff --git a/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingTasklet.java b/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingTasklet.java index d88aca3efa..f3f434572a 100644 --- a/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingTasklet.java +++ b/spring-batch-core-tests/src/main/java/org/springframework/batch/core/test/timeout/SleepingTasklet.java @@ -19,11 +19,13 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; public class SleepingTasklet implements Tasklet { private long millisToSleep; + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java index 18953da6de..7fb5b8edb2 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/concurrent/ConcurrentTransactionTests.java @@ -53,6 +53,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseConfigurer; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; +import org.springframework.lang.Nullable; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -154,6 +155,7 @@ public Flow flow() { return new FlowBuilder("flow") .start(stepBuilderFactory.get("flow.step1") .tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; @@ -161,6 +163,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon }).build() ).next(stepBuilderFactory.get("flow.step2") .tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; @@ -173,6 +176,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon public Step firstStep() { return stepBuilderFactory.get("firstStep") .tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println(">> Beginning concurrent job test"); @@ -185,6 +189,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon public Step lastStep() { return stepBuilderFactory.get("lastStep") .tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { System.out.println(">> Ending concurrent job test"); diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/MyMapper.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/MyMapper.java index a421cfcd31..03a5588567 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/MyMapper.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/MyMapper.java @@ -16,6 +16,7 @@ package org.springframework.batch.core.test.ldif; import org.springframework.batch.item.ldif.RecordMapper; +import org.springframework.lang.Nullable; import org.springframework.ldap.core.LdapAttributes; /** @@ -28,6 +29,7 @@ */ public class MyMapper implements RecordMapper { + @Nullable public LdapAttributes mapRecord(LdapAttributes attributes) { return attributes; } diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/builder/MappingLdifReaderBuilderTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/builder/MappingLdifReaderBuilderTests.java index 2a9e0bca79..207ff086b0 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/builder/MappingLdifReaderBuilderTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/ldif/builder/MappingLdifReaderBuilderTests.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; import org.springframework.ldap.core.LdapAttributes; import org.springframework.test.context.junit4.SpringRunner; @@ -210,6 +211,7 @@ public void handleRecord(LdapAttributes attributes) { } public class TestMapper implements RecordMapper { + @Nullable @Override public LdapAttributes mapRecord(LdapAttributes attributes) { return attributes; diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java index 0aa95c36c9..58b8822fd3 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/repository/JobSupport.java @@ -27,6 +27,7 @@ import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.core.job.DefaultJobParametersValidator; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -149,6 +150,7 @@ public boolean isRestartable() { /* (non-Javadoc) * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanIntegrationTests.java index a3e29216a9..45e895fea8 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanIntegrationTests.java @@ -48,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; +import org.springframework.lang.Nullable; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -189,6 +190,7 @@ public void clear() { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -273,6 +275,7 @@ public void clear() { jdbcTemplate.update("DELETE FROM ERROR_LOG where STEP_NAME='processed'"); } + @Nullable @Override public String process(String item) throws Exception { processed.add(item); diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanRollbackIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanRollbackIntegrationTests.java index eb5bba5c35..072e0df96c 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanRollbackIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepFactoryBeanRollbackIntegrationTests.java @@ -48,6 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; +import org.springframework.lang.Nullable; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -210,6 +211,7 @@ public void clear() { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -305,6 +307,7 @@ public void clear() { jdbcTemplate.update("DELETE FROM ERROR_LOG where STEP_NAME='processed'"); } + @Nullable @Override public String process(String item) throws Exception { processed.add(item); diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepIntegrationTests.java index bf74493b2b..50d6aa74c5 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/FaultTolerantStepIntegrationTests.java @@ -24,6 +24,7 @@ import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.PlatformTransactionManager; @@ -152,6 +153,7 @@ public void testExceptionInProcessDuringChunkScan() throws Exception { ItemProcessor itemProcessor = new ItemProcessor() { private int cpt; + @Nullable @Override public Integer process(Integer item) throws Exception { cpt++; diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanRollbackTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanRollbackTests.java index 474ef209d7..245abf9bbf 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanRollbackTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanRollbackTests.java @@ -41,6 +41,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.util.Assert; @@ -176,6 +177,7 @@ public void clear() { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception { counter++; @@ -236,6 +238,7 @@ public void clear() { processed.clear(); } + @Nullable @Override public String process(String item) throws Exception { processed.add(item); diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanTests.java index 18ab1ff3b1..514a61b9c1 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/MapRepositoryFaultTolerantStepFactoryBeanTests.java @@ -42,6 +42,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.util.Assert; @@ -172,6 +173,7 @@ public void clear() { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -226,6 +228,7 @@ public void clear() { processed.clear(); } + @Nullable @Override public String process(String item) throws Exception { processed.add(item); diff --git a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java index 8c16aef792..d1f3454dae 100644 --- a/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java +++ b/spring-batch-core-tests/src/test/java/org/springframework/batch/core/test/step/SplitJobMapRepositoryIntegrationTests.java @@ -33,6 +33,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -87,6 +88,7 @@ public static class CountingTasklet implements Tasklet { private AtomicInteger count = new AtomicInteger(0); + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.incrementReadCount(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java index 55daded091..849aa5bd06 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/MapJobRegistry.java @@ -25,6 +25,7 @@ import org.springframework.batch.core.configuration.JobFactory; import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.launch.NoSuchJobException; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -61,7 +62,7 @@ public void unregister(String name) { } @Override - public Job getJob(String name) throws NoSuchJobException { + public Job getJob(@Nullable String name) throws NoSuchJobException { JobFactory factory = map.get(name); if (factory == null) { throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered"); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java index 9c5c7b79cd..81a1d9c333 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java @@ -110,7 +110,7 @@ public JobExecution getLastJobExecution(JobInstance jobInstance) { * (java.lang.String) */ @Override - public Set findRunningJobExecutions(String jobName) { + public Set findRunningJobExecutions(@Nullable String jobName) { Set executions = jobExecutionDao.findRunningJobExecutions(jobName); for (JobExecution jobExecution : executions) { getJobExecutionDependencies(jobExecution); @@ -128,8 +128,9 @@ public Set findRunningJobExecutions(String jobName) { * org.springframework.batch.core.explore.JobExplorer#getJobExecution(java * .lang.Long) */ + @Nullable @Override - public JobExecution getJobExecution(Long executionId) { + public JobExecution getJobExecution(@Nullable Long executionId) { if (executionId == null) { return null; } @@ -151,8 +152,9 @@ public JobExecution getJobExecution(Long executionId) { * org.springframework.batch.core.explore.JobExplorer#getStepExecution(java * .lang.Long) */ + @Nullable @Override - public StepExecution getStepExecution(Long jobExecutionId, Long executionId) { + public StepExecution getStepExecution(@Nullable Long jobExecutionId, @Nullable Long executionId) { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { return null; @@ -170,6 +172,7 @@ public StepExecution getStepExecution(Long jobExecutionId, Long executionId) { * org.springframework.batch.core.explore.JobExplorer#getJobInstance(java * .lang.Long) */ + @Nullable @Override public JobInstance getJobInstance(@Nullable Long instanceId) { return jobInstanceDao.getJobInstance(instanceId); @@ -182,6 +185,7 @@ public JobInstance getJobInstance(@Nullable Long instanceId) { * org.springframework.batch.core.explore.JobExplorer#getLastJobInstance(java * .lang.String) */ + @Nullable @Override public JobInstance getLastJobInstance(String jobName) { return jobInstanceDao.getLastJobInstance(jobName); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index 808f1c4509..d099f5d7dd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -165,6 +165,7 @@ public String getName() { * @param stepName name of the step * @return the Step */ + @Nullable @Override public abstract Step getStep(String stepName); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java index 53b1919664..76bffe785c 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleJob.java @@ -29,6 +29,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.step.StepLocator; +import org.springframework.lang.Nullable; /** * Simple implementation of {@link Job} interface providing the ability to run a @@ -102,6 +103,7 @@ public void addStep(Step step) { * @see * org.springframework.batch.core.job.AbstractJob#getStep(java.lang.String) */ + @Nullable @Override public Step getStep(String stepName) { for (Step step : this.steps) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java index fff74e1dfb..cc133bd2ea 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/FlowJob.java @@ -27,6 +27,7 @@ import org.springframework.batch.core.job.SimpleStepHandler; import org.springframework.batch.core.step.StepHolder; import org.springframework.batch.core.step.StepLocator; +import org.springframework.lang.Nullable; /** * Implementation of the {@link Job} interface that allows for complex flows of @@ -73,6 +74,7 @@ public void setFlow(Flow flow) { /** * {@inheritDoc} */ + @Nullable @Override public Step getStep(String stepName) { if (!initialized) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java index 8e2e9bd830..38bb76f80a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/support/state/StepState.java @@ -27,6 +27,7 @@ import org.springframework.batch.core.step.NoSuchStepException; import org.springframework.batch.core.step.StepHolder; import org.springframework.batch.core.step.StepLocator; +import org.springframework.lang.Nullable; /** * {@link State} implementation that delegates to a {@link FlowExecutor} to @@ -99,6 +100,7 @@ public Collection getStepNames() { /* (non-Javadoc) * @see org.springframework.batch.core.step.StepLocator#getStep(java.lang.String) */ + @Nullable @Override public Step getStep(String stepName) throws NoSuchStepException { Step result = null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepListenerAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepListenerAdapter.java index 6933932b7e..c6034df74a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepListenerAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/StepListenerAdapter.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -51,6 +52,7 @@ public void beforeStep(StepExecution stepExecution) { } } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { try { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/PartitionStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/PartitionStep.java index 05654ba69b..9fb42b1197 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/PartitionStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/PartitionStep.java @@ -32,6 +32,7 @@ import org.springframework.batch.core.step.NoSuchStepException; import org.springframework.batch.core.step.StepLocator; import org.springframework.batch.item.ExecutionContext; +import org.springframework.lang.Nullable; /** * An extension of the {@link PartitionStep} that provides additional semantics @@ -102,6 +103,7 @@ public Collection getStepNames() { /* (non-Javadoc) * @see org.springframework.batch.core.step.StepLocator#getStep(java.lang.String) */ + @Nullable @Override public Step getStep(String stepName) throws NoSuchStepException { JsrPartitionHandler partitionHandler = (JsrPartitionHandler) getPartitionHandler(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/batchlet/BatchletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/batchlet/BatchletAdapter.java index e41dda27a0..ff81ced77f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/batchlet/BatchletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/jsr/step/batchlet/BatchletAdapter.java @@ -23,6 +23,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.StoppableTasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -40,6 +41,7 @@ public BatchletAdapter(Batchlet batchlet) { this.batchlet = batchlet; } + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java index d258a0476b..b57c2c69f7 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/CompositeStepExecutionListener.java @@ -22,6 +22,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.core.Ordered; +import org.springframework.lang.Nullable; /** * @author Lucas Ward @@ -55,6 +56,7 @@ public void register(StepExecutionListener stepExecutionListener) { * prioritizing those that implement {@link Ordered}. * @see org.springframework.batch.core.StepExecutionListener#afterStep(StepExecution) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { for (Iterator iterator = list.reverse(); iterator.hasNext();) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java index 7caae99b3a..464cb0fc71 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java @@ -22,6 +22,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.support.PatternMatcher; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -46,6 +47,7 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp private boolean strict = false; + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { ExecutionContext stepContext = stepExecution.getExecutionContext(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java index 5f82d7264e..9043303861 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/MulticasterBatchListener.java @@ -170,6 +170,7 @@ public void onProcessError(T item, Exception ex) { /** * @see org.springframework.batch.core.listener.CompositeStepExecutionListener#afterStep(StepExecution) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { try { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java index 04f037e715..b9b6e1fd39 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepExecutionListenerSupport.java @@ -18,6 +18,7 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -28,6 +29,7 @@ public class StepExecutionListenerSupport implements StepExecutionListener { /* (non-Javadoc) * @see org.springframework.batch.core.domain.StepListener#afterStep(StepExecution stepExecution) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java index 9ab7d72e3b..461f94342e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerSupport.java @@ -42,6 +42,7 @@ public class StepListenerSupport implements StepExecutionListener, ChunkLis /* (non-Javadoc) * @see org.springframework.batch.core.StepExecutionListener#afterStep(org.springframework.batch.core.StepExecution) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java index 15f2a7ab34..327d5a1311 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java @@ -243,6 +243,7 @@ public void updateJobExecution(JobExecution jobExecution) { } } + @Nullable @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java index e72cf3f312..066c97184a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MapJobExecutionDao.java @@ -106,6 +106,7 @@ public void updateJobExecution(JobExecution jobExecution) { } } + @Nullable @Override public JobExecution getLastJobExecution(@Nullable JobInstance jobInstance) { JobExecution lastExec = null; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/JobSynchronizationManager.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/JobSynchronizationManager.java index ce09fce6b4..8ba84f0348 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/JobSynchronizationManager.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/JobSynchronizationManager.java @@ -37,7 +37,7 @@ public class JobSynchronizationManager { private static final SynchronizationManagerSupport manager = new SynchronizationManagerSupport() { @Override - protected JobContext createNewContext(JobExecution execution, BatchPropertyContext args) { + protected JobContext createNewContext(JobExecution execution, @Nullable BatchPropertyContext args) { return new JobContext(execution); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java index 608ba7c792..44ad07a0bf 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepSynchronizationManager.java @@ -38,7 +38,7 @@ public class StepSynchronizationManager { new SynchronizationManagerSupport() { @Override - protected StepContext createNewContext(StepExecution execution, BatchPropertyContext propertyContext) { + protected StepContext createNewContext(StepExecution execution, @Nullable BatchPropertyContext propertyContext) { StepContext context; if(propertyContext != null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java index cd1246738c..7131fcf459 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/NoWorkFoundStepExecutionListener.java @@ -19,6 +19,7 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; +import org.springframework.lang.Nullable; /** * Fails the step if no items have been processed ( item count is 0). @@ -27,6 +28,7 @@ */ public class NoWorkFoundStepExecutionListener extends StepExecutionListenerSupport { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { if (stepExecution.getReadCount() == 0) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java index fcee1d89d3..d8e6f37735 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/ChunkOrientedTasklet.java @@ -22,6 +22,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * A {@link Tasklet} implementing variations on read-process-write item @@ -60,6 +61,7 @@ public void setBuffering(boolean buffering) { this.buffering = buffering; } + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java index 1ee2280e3c..3ed60bd9b8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/CallableTaskletAdapter.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -57,6 +58,7 @@ public void afterPropertiesSet() throws Exception { * the {@link StepContribution} and the attributes. * @see Tasklet#execute(StepContribution, ChunkContext) */ + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return callable.call(); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java index edc0ffe81e..0f8d76b7db 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/MethodInvokingTaskletAdapter.java @@ -20,6 +20,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.item.adapter.AbstractMethodInvokingDelegator; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * A {@link Tasklet} that wraps a method in a POJO. By default the return @@ -43,6 +44,7 @@ public class MethodInvokingTaskletAdapter extends AbstractMethodInvokingDelegato * * @see Tasklet#execute(StepContribution, ChunkContext) */ + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (getArguments() == null) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index 96f0c12388..71719e4bdb 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -35,6 +35,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.core.task.TaskExecutor; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -91,6 +92,7 @@ public class SystemCommandTasklet extends StepExecutionListenerSupport implement * Execute system command and map its exit code to {@link ExitStatus} using * {@link SystemProcessExitCodeMapper}. */ + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobBuilderConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobBuilderConfigurationTests.java index f1cd7b7bcf..362eebb076 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobBuilderConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobBuilderConfigurationTests.java @@ -39,6 +39,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -132,6 +133,7 @@ protected Step step2() throws Exception { @Bean protected Tasklet tasklet() { return new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws Exception { if (fail) { @@ -217,6 +219,7 @@ public Job beansConfigurerJob() throws Exception { protected Step step1() throws Exception { return steps.get("step1").tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobLoaderConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobLoaderConfigurationTests.java index 8b7bc06ba0..de6570732c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobLoaderConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobLoaderConfigurationTests.java @@ -42,6 +42,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ApplicationObjectSupport; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -146,6 +147,7 @@ protected Step step2() throws Exception { @Bean protected Tasklet tasklet() { return new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws Exception { return RepeatStatus.FINISHED; @@ -172,6 +174,7 @@ public Job vanillaJob() throws Exception { @Bean protected Step step3() throws Exception { return steps.get("step3").tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java index 4325e1b1d5..a86126477e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/JobScopeConfigurationTests.java @@ -43,6 +43,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -220,6 +221,7 @@ public SimpleHolder getValue() { public static class TaskletSupport implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/MapJobRepositoryConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/MapJobRepositoryConfigurationTests.java index 9df722f7aa..0665889a67 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/MapJobRepositoryConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/MapJobRepositoryConfigurationTests.java @@ -40,6 +40,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.context.support.GenericApplicationContext; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; public class MapJobRepositoryConfigurationTests { @@ -146,6 +147,7 @@ public static class MapRepositoryBatchConfiguration { @Bean Step step1 () { return stepFactory.get("step1").tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java index d27635ed6e..19c3fc5d3c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/annotation/StepScopeConfigurationTests.java @@ -37,6 +37,7 @@ import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.lang.Nullable; import java.util.concurrent.Callable; @@ -289,6 +290,7 @@ protected SimpleHolder value(@Value("#{stepExecution.stepName}") public static class TaskletSupport implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java index 9956f4782e..d6a95d3e2e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java @@ -36,6 +36,7 @@ import org.springframework.batch.core.step.StepLocator; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; +import org.springframework.lang.Nullable; import org.springframework.test.util.ReflectionTestUtils; /** @@ -236,7 +237,8 @@ public static class BasicStubJob implements Job { public void execute(JobExecution execution) { } - @Override + @Nullable + @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; } @@ -264,7 +266,8 @@ public Collection getStepNames() { return Collections.emptyList(); } - @Override + @Nullable + @Override public Step getStep(String stepName) throws NoSuchStepException { throw new NoSuchStepException("Step [" + stepName + "] does not exist"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java index 8e206d9620..e66fb32c71 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DecisionJobParserTests.java @@ -30,6 +30,7 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -59,7 +60,7 @@ public void testDecisionState() throws Exception { public static class TestDecider implements JobExecutionDecider { @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DefaultUnknownJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DefaultUnknownJobParserTests.java index 795ae01c15..8f5fd2dfc3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DefaultUnknownJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DefaultUnknownJobParserTests.java @@ -24,6 +24,7 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -57,6 +58,7 @@ public void testDefaultUnknown() throws Exception { } public static class UnknownListener extends StepExecutionListenerSupport { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { stepExecution.setStatus(BatchStatus.UNKNOWN); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java index 99c83fb300..d8df94107e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemProcessor.java @@ -16,6 +16,7 @@ package org.springframework.batch.core.configuration.xml; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -23,6 +24,7 @@ */ public class DummyItemProcessor implements ItemProcessor { + @Nullable @Override public Object process(Object item) throws Exception { return item; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java index f02754a607..96376daad5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyItemReader.java @@ -18,6 +18,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -25,6 +26,7 @@ */ public class DummyItemReader implements ItemReader { + @Nullable @Override public Object read() throws Exception, UnexpectedInputException, ParseException { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java index 485f265aa4..b308932d65 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java @@ -26,6 +26,7 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.JobRestartException; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -55,11 +56,13 @@ public JobExecution createJobExecution(String jobName, JobParameters jobParamete return null; } + @Nullable @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } + @Nullable @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java index 43d6a03c92..2197b271d5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyTasklet.java @@ -19,6 +19,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -26,6 +27,7 @@ */ public class DummyTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java index 27d1595bf1..8f5822e750 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FailingTasklet.java @@ -18,6 +18,7 @@ import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * This tasklet will call @@ -29,6 +30,7 @@ */ public class FailingTasklet extends NameStoringTasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { super.execute(contribution, chunkContext); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java index c7808e55ea..e8f66d4b0a 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/FlowStepParserTests.java @@ -35,6 +35,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -138,7 +139,7 @@ public static class Decider implements JobExecutionDecider { int count = 0; @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { if (count++ < 2) { return new FlowExecutionStatus("OK"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java index a0df6ca60f..fff0516449 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/InterruptibleTasklet.java @@ -18,6 +18,7 @@ import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * This tasklet will call @@ -31,6 +32,7 @@ public class InterruptibleTasklet extends NameStoringTasklet { private volatile boolean started = false; + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (!started) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java index 951441bb52..863df4da54 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NameStoringTasklet.java @@ -23,6 +23,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * This class will store the step name when it is executed. @@ -40,6 +41,7 @@ public void beforeStep(StepExecution stepExecution) { stepName = stepExecution.getStepName(); } + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (stepNamesList != null) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NextAttributeUnknownJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NextAttributeUnknownJobParserTests.java index 7855cc3e31..d9b529595d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NextAttributeUnknownJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NextAttributeUnknownJobParserTests.java @@ -24,6 +24,7 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.listener.StepExecutionListenerSupport; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -57,6 +58,7 @@ public void testDefaultUnknown() throws Exception { } public static class UnknownListener extends StepExecutionListenerSupport { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { stepExecution.setStatus(BatchStatus.UNKNOWN); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NoopTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NoopTasklet.java index caba40b802..21dc2463e2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NoopTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/NoopTasklet.java @@ -19,10 +19,12 @@ import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; public class NoopTasklet extends NameStoringTasklet { - @Override + @Nullable + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { super.execute(contribution, chunkContext); contribution.setExitStatus(ExitStatus.NOOP); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java index 2e861c265f..41cdbbf0dd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/PartitionStepWithFlowParserTests.java @@ -36,6 +36,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -96,7 +97,7 @@ public static class Decider implements JobExecutionDecider { int count = 0; @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { if (count++<2) { return new FlowExecutionStatus("OK"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java index bf23c0b10a..a1db770c48 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/StopJobParserTests.java @@ -26,6 +26,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.JobExecutionDecider; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -75,7 +76,7 @@ public void testStopState() throws Exception { public static class TestDecider implements JobExecutionDecider { @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { return new FlowExecutionStatus("FOO"); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java index 6420630bf3..6d98db43c5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestCustomStatusListener.java @@ -18,9 +18,11 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; +import org.springframework.lang.Nullable; public class TestCustomStatusListener extends AbstractTestComponent implements StepExecutionListener { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return new ExitStatus("FOO").and(stepExecution.getExitStatus()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java index bc54f40826..4823283e77 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestIncrementer.java @@ -17,11 +17,12 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersIncrementer; +import org.springframework.lang.Nullable; public class TestIncrementer implements JobParametersIncrementer{ @Override - public JobParameters getNext(JobParameters parameters) { + public JobParameters getNext(@Nullable JobParameters parameters) { return null; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java index 2dd9d97c1c..111b0e011d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestListener.java @@ -19,9 +19,11 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.annotation.AfterRead; +import org.springframework.lang.Nullable; public class TestListener extends AbstractTestComponent implements StepExecutionListener { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java index ea1d1a30eb..715cd6c67c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestProcessor.java @@ -16,9 +16,11 @@ package org.springframework.batch.core.configuration.xml; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; public class TestProcessor extends AbstractTestComponent implements ItemProcessor{ + @Nullable @Override public String process(String item) throws Exception { executed = true; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java index 356ed0414f..3c70ce757e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestReader.java @@ -22,6 +22,7 @@ import org.springframework.batch.item.ItemStreamReader; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; public class TestReader extends AbstractTestComponent implements ItemStreamReader { @@ -44,6 +45,7 @@ public void setOpened(boolean opened) { this.opened = opened; } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { executed = true; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java index bee5e84847..d4e3ecd250 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/TestTasklet.java @@ -19,11 +19,13 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; public class TestTasklet extends AbstractTestComponent implements Tasklet { private String name; + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/JobParametersConverterSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/JobParametersConverterSupport.java index 0978a4f5fe..120ee9eec8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/converter/JobParametersConverterSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/converter/JobParametersConverterSupport.java @@ -21,11 +21,12 @@ import org.springframework.batch.core.JobParameter; import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.lang.Nullable; public class JobParametersConverterSupport implements JobParametersConverter { @Override - public JobParameters getJobParameters(Properties properties) { + public JobParameters getJobParameters(@Nullable Properties properties) { JobParametersBuilder builder = new JobParametersBuilder(); if(properties != null) { @@ -43,7 +44,7 @@ public JobParameters getJobParameters(Properties properties) { * @see org.springframework.batch.core.converter.JobParametersConverter#getProperties(org.springframework.batch.core.JobParameters) */ @Override - public Properties getProperties(JobParameters params) { + public Properties getProperties(@Nullable JobParameters params) { Properties properties = new Properties(); if(params != null) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java index 5b20c5a2e8..dfc8e9a3d2 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/explore/support/MapJobExplorerIntegrationTests.java @@ -29,6 +29,7 @@ import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; import java.util.Set; @@ -56,6 +57,7 @@ public void testRunningJobExecution() throws Exception { SimpleJob job = new SimpleJob("job"); TaskletStep step = new TaskletStep("step"); step.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { while (block) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java index 4ea6b8bdac..7583b4bff0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/ExtendedAbstractJobTests.java @@ -28,6 +28,7 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import org.springframework.lang.Nullable; import java.util.Collection; import java.util.Collections; @@ -130,7 +131,7 @@ public void testValidatorWithNotNullParameters() throws Exception { public void testSetValidator() throws Exception { job.setJobParametersValidator(new DefaultJobParametersValidator() { @Override - public void validate(JobParameters parameters) throws JobParametersInvalidException { + public void validate(@Nullable JobParameters parameters) throws JobParametersInvalidException { throw new JobParametersInvalidException("FOO"); } }); @@ -214,6 +215,7 @@ public StubJob() { protected void doExecute(JobExecution execution) throws JobExecutionException { } + @Nullable @Override public Step getStep(String stepName) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java index 9bce003f27..8d689926bb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/JobSupport.java @@ -30,6 +30,7 @@ import org.springframework.batch.core.step.NoSuchStepException; import org.springframework.batch.core.step.StepLocator; import org.springframework.beans.factory.BeanNameAware; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -175,6 +176,7 @@ public String toString() { * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; @@ -190,6 +192,7 @@ public Collection getStepNames() { return steps.keySet(); } + @Nullable @Override public Step getStep(String stepName) throws NoSuchStepException { final Step step = steps.get(stepName); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java index 599ff9684a..2311e6cf13 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java @@ -34,6 +34,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -168,7 +169,7 @@ public void testBuildDecision() throws Exception { JobExecutionDecider decider = new JobExecutionDecider() { private int count = 0; @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { count++; return count<2 ? new FlowExecutionStatus("ONGOING") : FlowExecutionStatus.COMPLETED; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java index 69d4862306..b79ebb3f9e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/FlowJobTests.java @@ -41,6 +41,7 @@ import org.springframework.batch.core.repository.dao.JobExecutionDao; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import org.springframework.lang.Nullable; import java.util.ArrayList; import java.util.Arrays; @@ -458,7 +459,7 @@ public void testDecisionFlow() throws Throwable { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { assertNotNull(stepExecution); return new FlowExecutionStatus("SWITCH"); } @@ -500,7 +501,7 @@ public void testDecisionFlowWithExceptionInDecider() throws Throwable { SimpleFlow flow = new SimpleFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { assertNotNull(stepExecution); throw new RuntimeException("Foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java index 34e13531cf..d28a2cd443 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/flow/support/JobFlowExecutorSupport.java @@ -25,6 +25,7 @@ import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.FlowExecutor; import org.springframework.batch.core.repository.JobRestartException; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -43,6 +44,7 @@ public JobExecution getJobExecution() { return null; } + @Nullable @Override public StepExecution getStepExecution() { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemListenerParsingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemListenerParsingTests.java index 20a76bfffa..a7070a316b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemListenerParsingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemListenerParsingTests.java @@ -30,6 +30,7 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -116,7 +117,7 @@ public void beforeProcess(Object item) { } @Override - public void afterProcess(Object item, Object result) { + public void afterProcess(Object item, @Nullable Object result) { afterProcessCount++; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemSkipParsingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemSkipParsingTests.java index d8da4bd59b..ad62c7ec32 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemSkipParsingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/ItemSkipParsingTests.java @@ -20,6 +20,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; +import org.springframework.lang.Nullable; import javax.batch.api.chunk.listener.SkipProcessListener; import javax.batch.api.chunk.listener.SkipReadListener; @@ -83,6 +84,7 @@ public void test() throws Exception { public static class SkipErrorGeneratingReader implements ItemReader { private static int count = 0; + @Nullable @Override public String read() throws Exception { count++; @@ -104,6 +106,7 @@ public String read() throws Exception { public static class SkipErrorGeneratingProcessor implements ItemProcessor { private static int count = 0; + @Nullable @Override public String process(String item) throws Exception { count++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java index 8c6a9f77b5..4abd82c44d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/JobPropertyTests.java @@ -38,6 +38,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; @@ -288,6 +289,7 @@ public static class TestTasklet implements Tasklet { @BatchProperty private String p1; + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { org.springframework.util.Assert.isTrue("p1val".equals(p1), "Expected p1val, got " + p1); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/StepListenerParsingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/StepListenerParsingTests.java index d889a45384..e8d3ca59cd 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/StepListenerParsingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/configuration/xml/StepListenerParsingTests.java @@ -30,6 +30,7 @@ import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -69,6 +70,7 @@ public void beforeStep(StepExecution stepExecution) { countBeforeStep++; } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { countAfterStep++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java index 095411f57f..690ec594e0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/JsrFlowJobTests.java @@ -46,6 +46,7 @@ import org.springframework.batch.core.repository.dao.JobExecutionDao; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.step.StepSupport; +import org.springframework.lang.Nullable; import javax.batch.api.Decider; import java.util.ArrayList; @@ -515,7 +516,7 @@ public void testDecisionFlowWithExceptionInDecider() throws Throwable { SimpleFlow flow = new JsrFlow("job"); JobExecutionDecider decider = new JobExecutionDecider() { @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { assertNotNull(stepExecution); throw new RuntimeException("Foo"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/support/JsrFlowTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/support/JsrFlowTests.java index 03b6f84a4d..890b35865f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/support/JsrFlowTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/job/flow/support/JsrFlowTests.java @@ -30,6 +30,7 @@ import org.springframework.batch.core.job.flow.support.JobFlowExecutorSupport; import org.springframework.batch.core.job.flow.support.SimpleFlowTests; import org.springframework.batch.core.job.flow.support.StateTransition; +import org.springframework.lang.Nullable; public class JsrFlowTests extends SimpleFlowTests { @@ -66,6 +67,7 @@ public FlowExecutor(StepExecution stepExecution) { this.stepExecution = stepExecution; } + @Nullable @Override public StepExecution getStepExecution() { return stepExecution; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrChunkProcessorTests.java index 41fd29604e..327165e11b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrChunkProcessorTests.java @@ -43,6 +43,7 @@ import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; public class JsrChunkProcessorTests { @@ -313,6 +314,7 @@ public FailingListItemReader(List list) { super(list); } + @Nullable @Override public String read() { count++; @@ -330,6 +332,7 @@ public static class FailingCountingItemProcessor implements ItemProcessor list) { super(list); } + @Nullable @Override public String read() { count++; @@ -516,6 +518,7 @@ public static class FailingCountingItemProcessor implements ItemProcessor findRunningJobExecutions(String jobName) { + public Set findRunningJobExecutions(@Nullable String jobName) { return new HashSet<>(); } + @Nullable @Override - public JobExecution getJobExecution(Long executionId) { + public JobExecution getJobExecution(@Nullable Long executionId) { if (jobExecution != null) { return jobExecution; } @@ -502,16 +504,19 @@ private JobExecution createJobExecution(JobInstance jobInstance, BatchStatus sta return jobExecution; } + @Nullable @Override - public JobInstance getJobInstance(Long instanceId) { + public JobInstance getJobInstance(@Nullable Long instanceId) { throw new UnsupportedOperationException(); } + @Nullable @Override public JobInstance getLastJobInstance(String jobName) { return null; } + @Nullable @Override public JobExecution getLastJobExecution(JobInstance jobInstance) { return null; @@ -527,8 +532,9 @@ public List getJobInstances(String jobName, int start, int count) { return result; } + @Nullable @Override - public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) { + public StepExecution getStepExecution(@Nullable Long jobExecutionId, @Nullable Long stepExecutionId) { throw new UnsupportedOperationException(); } @@ -543,7 +549,7 @@ public List findJobInstancesByJobName(String jobName, int start, in } @Override - public int getJobInstanceCount(String jobName) + public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException { int count = 0; @@ -569,13 +575,13 @@ public static class StubJobParametersConverter implements JobParametersConverter static boolean called = false; @Override - public JobParameters getJobParameters(Properties properties) { + public JobParameters getJobParameters(@Nullable Properties properties) { called = true; return delegate.getJobParameters(properties); } @Override - public Properties getProperties(JobParameters params) { + public Properties getProperties(@Nullable JobParameters params) { throw new UnsupportedOperationException(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java index 8d636ed810..e0b3297224 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/SimpleJobOperatorTests.java @@ -53,6 +53,7 @@ import org.springframework.batch.core.step.tasklet.TaskletStep; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.support.PropertiesConverter; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -86,6 +87,7 @@ public class SimpleJobOperatorTests { public void setUp() throws Exception { job = new JobSupport("foo") { + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return parameters -> jobParameters; @@ -96,7 +98,7 @@ public JobParametersIncrementer getJobParametersIncrementer() { jobOperator.setJobRegistry(new MapJobRegistry() { @Override - public Job getJob(String name) throws NoSuchJobException { + public Job getJob(@Nullable String name) throws NoSuchJobException { if (name.equals("foo")) { return job; } @@ -120,13 +122,13 @@ public Set getJobNames() { jobOperator.setJobParametersConverter(new DefaultJobParametersConverter() { @Override - public JobParameters getJobParameters(Properties props) { + public JobParameters getJobParameters(@Nullable Properties props) { assertTrue("Wrong properties", props.containsKey("a")); return jobParameters; } @Override - public Properties getProperties(JobParameters params) { + public Properties getProperties(@Nullable JobParameters params) { return PropertiesConverter.stringToProperties("a=b"); } }); @@ -394,6 +396,7 @@ public void testStopTaskletException() throws Exception { JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null); StoppableTasklet tasklet = new StoppableTasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @@ -450,6 +453,7 @@ class MockJob extends AbstractJob { private TaskletStep taskletStep; + @Nullable @Override public Step getStep(String stepName) { return taskletStep; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java index e7254b7fd4..93c9f28ef0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/TestJobParametersIncrementer.java @@ -18,11 +18,12 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.JobParametersIncrementer; +import org.springframework.lang.Nullable; public class TestJobParametersIncrementer implements JobParametersIncrementer { @Override - public JobParameters getNext(JobParameters parameters) { + public JobParameters getNext(@Nullable JobParameters parameters) { return new JobParametersBuilder().addString("foo", "spam").toJobParameters(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java index ae2a9e9383..441ea5f190 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/CompositeStepExecutionListenerTests.java @@ -24,6 +24,7 @@ import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -44,6 +45,7 @@ public void testSetListeners() { JobExecution jobExecution = new JobExecution(1L); StepExecution stepExecution = new StepExecution("s1", jobExecution); listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { assertEquals(ExitStatus.STOPPED, stepExecution.getExitStatus()); @@ -51,6 +53,7 @@ public ExitStatus afterStep(StepExecution stepExecution) { return ExitStatus.FAILED; } }, new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("continue"); @@ -70,6 +73,7 @@ public void testSetListener() { JobExecution jobExecution = new JobExecution(1L); StepExecution stepExecution = new StepExecution("s1", jobExecution); listener.register(new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("fail"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java index ec142f5d5d..044c516ee9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ItemListenerErrorTests.java @@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -187,6 +188,7 @@ public static class FailingItemProcessor implements ItemProcessor { private int count = 0; + @Nullable @Override public String read() throws Exception { count++; @@ -267,7 +270,7 @@ public void beforeProcess(String item) { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { if (methodToThrowExceptionFrom.equals("afterProcess")) { throw new RuntimeException("afterProcess caused this Exception"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java index b0aaa1db64..2defe41501 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/MulticasterBatchListenerTests.java @@ -37,6 +37,7 @@ import org.springframework.batch.core.annotation.BeforeRead; import org.springframework.batch.core.annotation.BeforeWrite; import org.springframework.batch.core.scope.context.ChunkContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -61,6 +62,7 @@ public void testSetListeners() { JobExecution jobExecution = new JobExecution(1L); StepExecution stepExecution = new StepExecution("s1", jobExecution); multicast.setListeners(Arrays.asList(new StepListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { count++; @@ -82,6 +84,7 @@ public void testRegister() { JobExecution jobExecution = new JobExecution(1L); StepExecution stepExecution = new StepExecution("s1", jobExecution); multicast.register(new StepListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { count++; @@ -758,6 +761,7 @@ public void afterRead(Integer item) { * org.springframework.batch.core.listener.StepListenerSupport#afterStep * (org.springframework.batch.core.StepExecution) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { count++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java index 82ae92e2d4..8377b66171 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/StepListenerFactoryBeanTests.java @@ -55,6 +55,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.Ordered; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import static org.junit.Assert.assertEquals; @@ -377,6 +378,7 @@ private class MultipleAfterStep implements StepExecutionListener { int callcount = 0; + @Nullable @Override @AfterStep public ExitStatus afterStep(StepExecution stepExecution) { @@ -397,6 +399,7 @@ private class ThreeStepExecutionListener implements StepExecutionListener { int callcount = 0; + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { Assert.notNull(stepExecution, "A stepExecution is required"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java index da5306e464..24dbefa7b9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/partition/ExampleItemReader.java @@ -21,6 +21,7 @@ import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.ItemStreamReader; import org.springframework.batch.item.support.AbstractItemStreamItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; /** @@ -61,6 +62,7 @@ public void setMax(int max) { /** * Reads next record from input */ + @Nullable @Override public String read() throws Exception { if (index >= input.length || index >= max) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java index d4fae4a301..4bba79027d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/OptimisticLockingFailureTests.java @@ -36,6 +36,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.lang.Nullable; public class OptimisticLockingFailureTests { @Test @@ -104,6 +105,7 @@ public void write(List items) throws Exception { } public static class SleepingTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Thread.sleep(2000L); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java index a1e53b9e1f..30145eadf3 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/TablePrefixTests.java @@ -32,6 +32,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.jdbc.JdbcTestUtils; @@ -62,6 +63,7 @@ public void testJobLaunch() throws Exception { public static class TestTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestJob.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestJob.java index 8fb1170c9f..f6f281e541 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestJob.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/TestJob.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.JobParametersValidator; import org.springframework.batch.core.scope.context.JobContext; import org.springframework.batch.core.scope.context.JobSynchronizationManager; +import org.springframework.lang.Nullable; public class TestJob implements Job { @@ -69,6 +70,7 @@ public boolean isRestartable() { return false; } + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java index 55339d9f83..19ec9f70d8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/JobRepositorySupport.java @@ -22,6 +22,7 @@ import org.springframework.batch.core.JobParameters; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.repository.JobRepository; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -52,6 +53,7 @@ public void update(JobExecution jobExecution) { public void update(JobInstance job) { } + @Nullable @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; @@ -90,6 +92,7 @@ public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) return false; } + @Nullable @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java index e95ad59c4c..ec8f364668 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/NonAbstractStepTests.java @@ -33,6 +33,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.item.ExecutionContext; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -98,6 +99,7 @@ private String getEvent(String event) { return name + "#" + event; } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { assertSame(execution, stepExecution); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartInPriorStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartInPriorStepTests.java index efbdef930a..f4b0104ab0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartInPriorStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartInPriorStepTests.java @@ -32,6 +32,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -71,6 +72,7 @@ public void test() throws Exception { public static class DecidingTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @@ -93,7 +95,7 @@ public static class CompletionDecider implements JobExecutionDecider { @Override public FlowExecutionStatus decide(JobExecution jobExecution, - StepExecution stepExecution) { + @Nullable StepExecution stepExecution) { count++; if(count > 2) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartLoopTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartLoopTests.java index 275b7be294..9aa7aed797 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartLoopTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/RestartLoopTests.java @@ -27,6 +27,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -59,6 +60,7 @@ public void test() throws Exception { } public static class DefaultTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return RepeatStatus.FINISHED; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/RegisterMultiListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/RegisterMultiListenerTests.java index e5606eed19..43b9684abb 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/RegisterMultiListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/RegisterMultiListenerTests.java @@ -52,6 +52,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; @@ -160,6 +161,7 @@ public ItemReader reader(){ private int count = 0; + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException, @@ -310,6 +312,7 @@ public void beforeStep(StepExecution stepExecution) { callChecker.beforeStepCalled++; } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java index f0e8402a84..191e3e7e3c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/StepBuilderTests.java @@ -47,6 +47,7 @@ import org.springframework.batch.item.support.ListItemWriter; import org.springframework.batch.item.support.PassThroughItemProcessor; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; import org.springframework.transaction.PlatformTransactionManager; import static org.junit.Assert.assertEquals; @@ -256,6 +257,7 @@ public void beforeStep(StepExecution stepExecution) { beforeStepCount++; } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { afterStepCount++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java index 60b1c86d98..0066e9efbe 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkMonitorTests.java @@ -26,6 +26,7 @@ import org.springframework.batch.item.ItemStreamSupport; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -44,6 +45,7 @@ public class ChunkMonitorTests { @Before public void setUp() { monitor.setItemReader(new ItemReader() { + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); @@ -109,6 +111,7 @@ public void testOpenWithNullReader() { @Test(expected = ItemStreamException.class) public void testOpenWithErrorInReader() { monitor.setItemReader(new ItemReader() { + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new IllegalStateException("Expected"); @@ -143,6 +146,7 @@ public void testUpdateVanilla() { public void testUpdateWithNoStream() throws Exception { monitor = new ChunkMonitor(); monitor.setItemReader(new ItemReader() { + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return "" + (count++); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java index 3f866a30b5..f0609e18de 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ExceptionThrowingTaskletStub.java @@ -25,6 +25,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -56,6 +57,7 @@ public void clear() { committed.clear(); } + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { committed.add(1); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java index 8979b3cfa2..46fc0fc080 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProcessorTests.java @@ -37,6 +37,7 @@ import org.springframework.batch.item.support.PassThroughItemProcessor; import org.springframework.classify.BinaryExceptionClassifier; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.lang.Nullable; import org.springframework.retry.RetryException; import org.springframework.retry.policy.NeverRetryPolicy; import org.springframework.retry.policy.SimpleRetryPolicy; @@ -84,6 +85,7 @@ public void testWrite() throws Exception { @Test public void testTransform() throws Exception { processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { return item.equals("1") ? null : item; @@ -99,6 +101,7 @@ public String process(String item) throws Exception { public void testFilterCountOnSkip() throws Exception { processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { if (item.equals("1")) { @@ -128,6 +131,7 @@ public String process(String item) throws Exception { public void testFilterCountOnSkipInWriteWithoutRetry() throws Exception { processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { if (item.equals("1")) { @@ -156,6 +160,7 @@ public void testFilterCountOnSkipInWriteWithRetry() throws Exception { batchRetryTemplate.setRetryPolicy(retryPolicy); processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { if (item.equals("1")) { @@ -271,6 +276,7 @@ public void write(List items) throws Exception { @Test public void testTransformWithExceptionAndNoRollback() throws Exception { processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { if (item.equals("1")) { @@ -563,6 +569,7 @@ public void testProcessFilterAndSkippableException() throws Exception { processor.setProcessorTransactional(false); processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processedItems.add(item); @@ -605,6 +612,7 @@ public void testProcessFilterAndSkippableExceptionNoRollback() throws Exception processor.setProcessorTransactional(false); processor.setProcessSkipPolicy(new AlwaysSkipItemSkipPolicy()); processor.setItemProcessor(new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processedItems.add(item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java index 35fff686a4..f86b5872a3 100755 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantChunkProviderTests.java @@ -33,6 +33,7 @@ import org.springframework.batch.item.UnexpectedInputException; import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.repeat.support.RepeatTemplate; +import org.springframework.lang.Nullable; public class FaultTolerantChunkProviderTests { @@ -53,6 +54,7 @@ public void testProvide() throws Exception { @Test public void testProvideWithOverflow() throws Exception { provider = new FaultTolerantChunkProvider<>(new ItemReader() { + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { throw new RuntimeException("Planned"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java index e5700a3525..fd6b78f608 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanRetryTests.java @@ -53,6 +53,7 @@ import org.springframework.batch.item.support.ListItemReader; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; +import org.springframework.lang.Nullable; import org.springframework.retry.policy.MapRetryContextCache; import org.springframework.retry.policy.SimpleRetryPolicy; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -156,6 +157,7 @@ public void write(List data) throws Exception { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public Integer process(String item) throws Exception { processed.add(item); @@ -205,6 +207,7 @@ public void write(List data) throws Exception { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processed.add(item); @@ -253,6 +256,7 @@ public void write(List data) throws Exception { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processed.add(item); @@ -290,6 +294,7 @@ public String process(String item) throws Exception { public void testSuccessfulRetryWithReadFailure() throws Exception { ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c")) { + @Nullable @Override public String read() { String item = super.read(); @@ -344,6 +349,7 @@ protected void doOpen() throws Exception { "c", "d", "e", "f")); } + @Nullable @Override protected String doRead() throws Exception { return reader.read(); @@ -394,6 +400,7 @@ public void testSkipAndRetry() throws Exception { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Nullable @Override public String read() { String item = super.read(); @@ -435,6 +442,7 @@ public void onSkipInWrite(String item, Throwable t) { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Nullable @Override public String read() { String item = super.read(); @@ -499,6 +507,7 @@ public void onSkipInWrite(String item, Throwable t) { factory.setSkipLimit(2); ItemReader provider = new ListItemReader(Arrays.asList( "a", "b", "c", "d", "e", "f")) { + @Nullable @Override public String read() { String item = super.read(); @@ -557,6 +566,7 @@ public void testRetryWithNoSkip() throws Exception { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -612,6 +622,7 @@ public void testNonSkippableException() throws Exception { factory.setSkipLimit(1); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -665,6 +676,7 @@ public void testRetryPolicy() throws Exception { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -715,6 +727,7 @@ public void testCacheLimitWithRetry() throws Exception { // set the cache limit stupidly low factory.setRetryContextCache(new MapRetryContextCache(0)); ItemReader provider = new ItemReader() { + @Nullable @Override public String read() { String item = "" + count; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java index 765b8094a1..0c761f13d6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanTests.java @@ -66,6 +66,7 @@ import org.springframework.batch.item.support.AbstractItemStreamItemReader; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.beans.factory.FactoryBean; +import org.springframework.lang.Nullable; import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.util.StringUtils; @@ -792,7 +793,7 @@ public void onWriteError(Exception exception, List items) { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { listenerCalls.add(3); } @@ -863,6 +864,7 @@ public void open(ExecutionContext executionContext) { opened = true; } + @Nullable @Override public String read() { return null; @@ -901,6 +903,7 @@ public void open(ExecutionContext executionContext) throws ItemStreamException { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -922,6 +925,7 @@ public void open(ExecutionContext executionContext) throws ItemStreamException { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -963,6 +967,7 @@ public void open(ExecutionContext executionContext) throws ItemStreamException { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -997,7 +1002,7 @@ private static class ItemProcessListenerStub implements ItemProcessListene private boolean filterEncountered = false; @Override - public void afterProcess(T item, S result) { + public void afterProcess(T item, @Nullable S result) { if (result == null) { filterEncountered = true; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java index 5548462db7..8e4b2cd35f 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleChunkProcessorTests.java @@ -30,11 +30,13 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemWriter; +import org.springframework.lang.Nullable; public class SimpleChunkProcessorTests { private SimpleChunkProcessor processor = new SimpleChunkProcessor<>( new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { if (item.equals("err")) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java index 69c7c97c01..926f9fdd6d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java @@ -59,6 +59,7 @@ import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; /** * Tests for {@link SimpleStepFactoryBean}. @@ -381,6 +382,7 @@ class TestItemListenerWriter implements ItemWriter, ItemProcessor items) throws Exception { } + @Nullable @Override public String process(String item) throws Exception { return item; @@ -413,7 +415,7 @@ public void onWriteError(Exception exception, List items) { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { listenerCalls.add("process"); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java index ec97c30a05..0ab7a24de5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipProcessorStub.java @@ -20,6 +20,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.support.transaction.TransactionAwareProxyFactory; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -55,6 +56,7 @@ public void clear() { filter = false; } + @Nullable @Override public T process(T item) throws Exception { processed.add(item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java index bad4efe3cc..d6983e4218 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SkipReaderStub.java @@ -21,6 +21,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -60,6 +61,7 @@ public void clear() { read.clear(); } + @Nullable @Override public T read() throws Exception, UnexpectedInputException, ParseException { counter++; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java index 9ac4ca1210..41e3671d74 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java @@ -40,6 +40,7 @@ import org.springframework.batch.item.ItemStreamSupport; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; import org.springframework.transaction.TransactionException; import org.springframework.transaction.UnexpectedRollbackException; import org.springframework.transaction.support.DefaultTransactionStatus; @@ -106,6 +107,7 @@ public void testInterrupted() throws Exception { @Test public void testInterruptedWithCustomStatus() throws Exception { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(new ExitStatus("FUNNY")); @@ -154,6 +156,7 @@ public void testAfterStepFailureWhenTaskletSucceeds() throws Exception { final RuntimeException exception = new RuntimeException(); taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { throw exception; @@ -161,6 +164,7 @@ public ExitStatus afterStep(StepExecution stepExecution) { } }); taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -181,6 +185,7 @@ public void testAfterStepFailureWhenTaskletFails() throws Exception { final RuntimeException exception = new RuntimeException(); taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { throw exception; @@ -230,6 +235,7 @@ protected void doRollback(DefaultTransactionStatus status) throws TransactionExc taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); @@ -265,6 +271,7 @@ protected void doCommit(DefaultTransactionStatus status) throws TransactionExcep taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { attributes.getStepContext().getStepExecution().getExecutionContext().putString("foo", "bar"); @@ -291,6 +298,7 @@ public void testRepositoryErrorOnExecutionContext() throws Exception { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -311,6 +319,7 @@ public void testRepositoryErrorOnExecutionContextInTransaction() throws Exceptio taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -332,6 +341,7 @@ public void testRepositoryErrorOnExecutionContextInTransactionRollbackFailed() t taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -355,6 +365,7 @@ public void testRepositoryErrorOnUpdateStepExecution() throws Exception { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -375,6 +386,7 @@ public void testRepositoryErrorOnUpdateStepExecutionInTransaction() throws Excep taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -396,6 +408,7 @@ public void testRepositoryErrorOnUpdateStepExecutionInTransactionRollbackFailed( taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -419,6 +432,7 @@ public void testRepositoryErrorOnFailure() throws Exception { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { throw new RuntimeException("Tasklet exception"); @@ -459,6 +473,7 @@ public void update(StepExecution arg0) { private static class ExceptionTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw taskletException; @@ -505,6 +520,7 @@ public JobExecution createJobExecution(String jobName, JobParameters jobParamete return null; } + @Nullable @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; @@ -548,6 +564,7 @@ public int getUpdateCount() { return updateCount; } + @Nullable @Override public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java index 400af1668f..c4cd60356e 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/skip/ReprocessExceptionTests.java @@ -25,6 +25,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -56,6 +57,7 @@ public static class PersonProcessor implements ItemProcessor { private String mostRecentFirstName; + @Nullable @Override public Person process(final Person person) throws Exception { if (person.getFirstName().equals(mostRecentFirstName)) { diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java index 913c14a5cf..427ae105b5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/AsyncTaskletStepTests.java @@ -44,6 +44,7 @@ import org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; public class AsyncTaskletStepTests { @@ -175,6 +176,7 @@ public void testStepExecutionFailsWithProcessor() throws Exception { concurrencyLimit = 1; items = Arrays.asList("one", "barf", "three", "four"); itemProcessor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { logger.info("Item: "+item); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index 84c65c4d99..dc1709e01b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -45,6 +45,7 @@ import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.repeat.support.RepeatTemplate; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; +import org.springframework.lang.Nullable; public class StepExecutorInterruptionTests { @@ -93,6 +94,7 @@ public void testInterruptStep() throws Exception { // N.B, If we don't set the completion policy it might run forever template.setCompletionPolicy(new SimpleCompletionPolicy(2)); step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader() { + @Nullable @Override public Object read() throws Exception { // do something non-trivial (and not Thread.sleep()) @@ -155,6 +157,7 @@ public void release() { Thread processingThread = createThread(stepExecution); step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader() { + @Nullable @Override public Object read() throws Exception { return null; @@ -200,6 +203,7 @@ public void release() { }); step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader() { + @Nullable @Override public Object read() throws Exception { throw new RuntimeException("Planned!"); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index b656c34b20..a6e07beac5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -63,6 +63,7 @@ import org.springframework.batch.repeat.support.RepeatTemplate; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.dao.DataAccessResourceFailureException; +import org.springframework.lang.Nullable; import org.springframework.transaction.TransactionException; import org.springframework.transaction.interceptor.DefaultTransactionAttribute; import org.springframework.transaction.support.DefaultTransactionStatus; @@ -246,6 +247,7 @@ public void testIncrementRollbackCount() { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -271,6 +273,7 @@ public void testExitCodeDefaultClassification() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -297,6 +300,7 @@ public void testExitCodeCustomClassification() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -307,6 +311,7 @@ public String read() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet<>(itemReader, itemWriter)); step.registerStepExecutionListener(new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return ExitStatus.FAILED.addExitDescription("FOO"); @@ -414,6 +419,7 @@ public void testNoSaveExecutionAttributesRestartableJob() { @Test public void testRestartJobOnNonRestartableTasklet() throws Exception { step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader() { + @Nullable @Override public String read() throws Exception { return "foo"; @@ -428,6 +434,7 @@ public String read() throws Exception { @Test public void testStreamManager() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Nullable @Override public String read() { return "foo"; @@ -480,6 +487,7 @@ public void beforeStep(StepExecution stepExecution) { list.add("foo"); } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("bar"); @@ -519,6 +527,7 @@ public void testAfterStep() throws Exception { final ExitStatus customStatus = new ExitStatus("COMPLETED_CUSTOM"); step.setStepExecutionListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("afterStepCalled"); @@ -542,6 +551,7 @@ public ExitStatus afterStep(StepExecution stepExecution) { @Test public void testDirectlyInjectedListenerOnError() throws Exception { step.registerStepExecutionListener(new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("exception"); @@ -549,6 +559,7 @@ public ExitStatus afterStep(StepExecution stepExecution) { } }); step.setTasklet(new TestingChunkOrientedTasklet<>(new MockRestartableItemReader() { + @Nullable @Override public String read() throws RuntimeException { throw new RuntimeException("FOO"); @@ -564,6 +575,7 @@ public String read() throws RuntimeException { @Test public void testDirectlyInjectedStreamWhichIsAlsoReader() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Nullable @Override public String read() { return "foo"; @@ -604,6 +616,7 @@ public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedE ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -630,6 +643,7 @@ public String read() throws Exception { public void testStatusForNormalFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -654,6 +668,7 @@ public String read() throws Exception { public void testStatusForErrorFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -679,6 +694,7 @@ public String read() throws Exception { public void testStatusForResetFailedException() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -801,6 +817,7 @@ public void close() throws ItemStreamException { @Test public void testRestartAfterFailureInFirstChunk() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Nullable @Override public String read() throws RuntimeException { // fail on the very first item @@ -845,6 +862,7 @@ public void testStepToCompletion() throws Exception { @Test public void testStepFailureInAfterStepCallback() throws JobInterruptedException { StepExecutionListener listener = new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { throw new RuntimeException("exception thrown in afterStep to signal failure"); @@ -862,6 +880,7 @@ public ExitStatus afterStep(StepExecution stepExecution) { public void testNoRollbackFor() throws Exception { step.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw new RuntimeException("Bar"); @@ -887,6 +906,7 @@ public boolean rollbackOn(Throwable ex) { @Test public void testTaskletExecuteReturnNull() throws Exception { step.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; @@ -931,6 +951,7 @@ private class MockRestartableItemReader extends AbstractItemStreamItemReader() { + @Nullable @Override public String read() { String text = (String) jmsTemplate.receiveAndConvert("queue"); diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java index eaa2faf25e..992d8348ea 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jms.core.JmsTemplate; +import org.springframework.lang.Nullable; import org.springframework.retry.RecoveryCallback; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; @@ -71,6 +72,7 @@ public void onSetUp() throws Exception { jdbcTemplate.execute("delete from T_BARS"); jmsTemplate.convertAndSend("queue", "foo"); provider = new ItemReader() { + @Nullable @Override public String read() { String text = (String) jmsTemplate.receiveAndConvert("queue"); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java index 5572d72050..25114953d4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/adapter/ItemProcessorAdapter.java @@ -17,6 +17,7 @@ package org.springframework.batch.item.adapter; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; /** * Invokes a custom method on a delegate plain old Java object which itself @@ -31,6 +32,7 @@ public class ItemProcessorAdapter extends AbstractMethodInvokingDelegator extends AbstractMethodInvokingDelegator imp /** * @return return value of the target method. */ + @Nullable @Override public T read() throws Exception { return invokeDelegateMethod(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java index b4a5302407..1fa01a9bb4 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/amqp/AmqpItemReader.java @@ -19,6 +19,7 @@ import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.core.Message; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -45,6 +46,7 @@ public AmqpItemReader(final AmqpTemplate amqpTemplate) { this.amqpTemplate = amqpTemplate; } + @Nullable @Override @SuppressWarnings("unchecked") public T read() { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro/AvroItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro/AvroItemReader.java index e34dc83079..3725ad5e61 100755 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro/AvroItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/avro/AvroItemReader.java @@ -33,6 +33,7 @@ import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -101,6 +102,7 @@ public void setEmbeddedSchema(boolean embeddedSchema) { } + @Nullable @Override protected T doRead() throws Exception { if (this.inputStreamReader != null) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/AbstractPaginatedDataItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/AbstractPaginatedDataItemReader.java index 2454bdae85..396959c6c9 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/AbstractPaginatedDataItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/AbstractPaginatedDataItemReader.java @@ -18,6 +18,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStreamReader; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import java.util.Iterator; @@ -53,6 +54,7 @@ public void setPageSize(int pageSize) { this.pageSize = pageSize; } + @Nullable @Override protected T doRead() throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java index e0b319d7bc..1ea3258230 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java @@ -33,6 +33,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.MethodInvoker; @@ -150,6 +151,7 @@ public void afterPropertiesSet() throws Exception { Assert.state(sort != null, "A sort is required"); } + @Nullable @Override protected T doRead() throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java index 51725be4b3..c4c6c58536 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java @@ -465,6 +465,7 @@ protected void initializeConnection() { * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */ + @Nullable @Override protected T doRead() throws Exception { if (rs == null) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java index ac161133b2..27cdd05579 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractPagingItemReader.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -94,6 +95,7 @@ public void afterPropertiesSet() throws Exception { Assert.isTrue(pageSize > 0, "pageSize must be greater than zero"); } + @Nullable @Override protected T doRead() throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java index 1ece059b52..155d820a4d 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/HibernateCursorItemReader.java @@ -27,6 +27,7 @@ import org.springframework.batch.item.database.orm.HibernateQueryProvider; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -150,6 +151,7 @@ public void setUseStatelessSession(boolean useStatelessSession) { helper.setUseStatelessSession(useStatelessSession); } + @Nullable @Override protected T doRead() throws Exception { if (cursor.next()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java index ba69ae46c7..94a7d4c1ed 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcCursorItemReader.java @@ -24,6 +24,7 @@ import org.springframework.jdbc.core.PreparedStatementSetter; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.JdbcUtils; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -134,6 +135,7 @@ protected void openCursor(Connection con) { } + @Nullable @Override protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return rowMapper.mapRow(rs, currentRow); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java index bff3dc3b93..fda9101da8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/StoredProcedureItemReader.java @@ -29,6 +29,7 @@ import org.springframework.jdbc.core.SqlParameter; import org.springframework.jdbc.core.metadata.CallMetaDataContext; import org.springframework.jdbc.support.JdbcUtils; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -230,6 +231,7 @@ protected void openCursor(Connection con) { } + @Nullable @Override protected T readCursor(ResultSet rs, int currentRow) throws SQLException { return rowMapper.mapRow(rs, currentRow); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java index b5ab389ce7..860f24dbf6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemReader.java @@ -29,6 +29,7 @@ import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -164,6 +165,7 @@ public void setRecordSeparatorPolicy(RecordSeparatorPolicy recordSeparatorPolicy * @return string corresponding to logical record according to * {@link #setRecordSeparatorPolicy(RecordSeparatorPolicy)} (might span multiple lines in file). */ + @Nullable @Override protected T doRead() throws Exception { if (noInput) { @@ -189,7 +191,8 @@ protected T doRead() throws Exception { /** * @return next line (skip comments).getCurrentResource */ - private String readLine() { + @Nullable + protected String readLine() { if (reader == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java index 25a10b6911..f3c78bc2d6 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/MultiResourceItemReader.java @@ -92,6 +92,7 @@ public MultiResourceItemReader() { /** * Reads the next item, jumping to next resource if necessary. */ + @Nullable @Override public T read() throws Exception, UnexpectedInputException, ParseException { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java index 88da1b04f0..ceaa86e63e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/AbstractLineTokenizer.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.List; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; /** @@ -120,7 +121,7 @@ public boolean hasNames() { * @return the resulting tokens */ @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { if (line == null) { line = ""; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java index e3549e91a1..11e8362cd0 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizer.java @@ -20,6 +20,7 @@ import org.springframework.batch.support.PatternMatcher; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -46,7 +47,7 @@ public class PatternMatchingCompositeLineTokenizer implements LineTokenizer, Ini * java.lang.String) */ @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return tokenizers.match(line).tokenize(line); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/function/FunctionItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/function/FunctionItemProcessor.java index e5ecadec40..28009f3cbc 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/function/FunctionItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/function/FunctionItemProcessor.java @@ -18,6 +18,7 @@ import java.util.function.Function; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -38,6 +39,7 @@ public FunctionItemProcessor(Function function) { this.function = function; } + @Nullable @Override public O process(I item) throws Exception { return this.function.apply(item); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java index 0d7ee66544..cc7a7a8f63 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/jms/JmsItemReader.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.jms.core.JmsOperations; import org.springframework.jms.core.JmsTemplate; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import javax.jms.Message; @@ -76,7 +77,8 @@ public void setItemType(Class itemType) { this.itemType = itemType; } - @Override + @Nullable + @Override @SuppressWarnings("unchecked") public T read() { if (itemType != null && itemType.isAssignableFrom(Message.class)) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java index 159f66d3ab..7952f3931e 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/GsonJsonObjectReader.java @@ -28,6 +28,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -76,6 +77,7 @@ public void open(Resource resource) throws Exception { this.jsonReader.beginArray(); } + @Nullable @Override public T read() throws Exception { try { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java index db1c228cfd..8ffec6dedc 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JacksonJsonObjectReader.java @@ -25,6 +25,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -72,6 +73,7 @@ public void open(Resource resource) throws Exception { "The Json input stream must start with an array of Json objects"); } + @Nullable @Override public T read() throws Exception { try { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java index 89525c398f..3ca7d6e268 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/json/JsonItemReader.java @@ -23,6 +23,7 @@ import org.springframework.batch.item.file.ResourceAwareItemReaderItemStream; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -94,6 +95,7 @@ public void setResource(Resource resource) { this.resource = resource; } + @Nullable @Override protected T doRead() throws Exception { return jsonObjectReader.read(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemReader.java index a2cc6aca5e..a022b27eac 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/kafka/KafkaItemReader.java @@ -32,6 +32,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.support.AbstractItemStreamItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -156,6 +157,7 @@ public void open(ExecutionContext executionContext) { this.partitionOffsets.forEach(this.kafkaConsumer::seek); } + @Nullable @Override public V read() { if (this.consumerRecords == null || !this.consumerRecords.hasNext()) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/LdifReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/LdifReader.java index 3b17116d8f..87e887837c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/LdifReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/LdifReader.java @@ -22,6 +22,7 @@ import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.ldap.core.LdapAttributes; import org.springframework.ldap.ldif.parser.LdifParser; import org.springframework.util.Assert; @@ -134,6 +135,7 @@ protected void doOpen() throws Exception { } } + @Nullable @Override protected LdapAttributes doRead() throws Exception { LdapAttributes attributes = null; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/MappingLdifReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/MappingLdifReader.java index f5e3eb5129..46f3879983 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/MappingLdifReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ldif/MappingLdifReader.java @@ -21,6 +21,7 @@ import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.ldap.core.LdapAttributes; import org.springframework.ldap.ldif.parser.LdifParser; import org.springframework.util.Assert; @@ -138,6 +139,7 @@ protected void doOpen() throws Exception { } } + @Nullable @Override protected T doRead() throws Exception { LdapAttributes attributes = null; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java index 3ba49fdfab..73eedde27b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/AbstractItemCountingItemStreamItemReader.java @@ -83,6 +83,7 @@ protected void jumpToItem(int itemIndex) throws Exception { } } + @Nullable @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (currentItemCount >= maxItemCount) { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessor.java index 338d09c5e7..092005faf8 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessor.java @@ -19,6 +19,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.classify.Classifier; import org.springframework.classify.ClassifierSupport; +import org.springframework.lang.Nullable; /** * Calls one of a collection of ItemProcessors, based on a router @@ -47,6 +48,7 @@ public void setClassifier(Classifier> c * Delegates to injected {@link ItemProcessor} instances according to the * classification by the {@link Classifier}. */ + @Nullable @Override public O process(I item) throws Exception { return processItem(classifier.classify(item), item); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java index 917eced093..6bac783174 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/CompositeItemProcessor.java @@ -18,6 +18,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import java.util.List; @@ -37,6 +38,7 @@ public class CompositeItemProcessor implements ItemProcessor, Initia private List> delegates; + @Nullable @Override @SuppressWarnings("unchecked") public O process(I item) throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java index 2919b8ab09..54d1536e30 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/IteratorItemReader.java @@ -19,6 +19,7 @@ import java.util.Iterator; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -62,7 +63,8 @@ public IteratorItemReader(Iterator iterator) { * Implementation of {@link ItemReader#read()} that just iterates over the * iterator provided. */ - @Override + @Nullable + @Override public T read() { if (iterator.hasNext()) return iterator.next(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java index ae364f4f19..67bdef313f 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ListItemReader.java @@ -21,6 +21,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; /** * An {@link ItemReader} that pulls data from a list. Useful for testing. @@ -43,7 +44,8 @@ public ListItemReader(List list) { } } - @Override + @Nullable + @Override public T read() { if (!list.isEmpty()) { return list.remove(0); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java index 5621e1b21b..f8e113ea44 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/PassThroughItemProcessor.java @@ -17,6 +17,7 @@ package org.springframework.batch.item.support; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; /** * Simple {@link ItemProcessor} that does nothing - simply passes its argument @@ -35,7 +36,8 @@ public class PassThroughItemProcessor implements ItemProcessor { * @return the item * @see ItemProcessor#process(Object) */ - @Override + @Nullable + @Override public T process(T item) throws Exception { return item; } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java index 18f74f94e8..f35f0b6f66 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java @@ -15,6 +15,7 @@ */ package org.springframework.batch.item.support; +import org.springframework.lang.Nullable; import org.springframework.scripting.support.StaticScriptSource; import org.springframework.util.StringUtils; import org.springframework.batch.item.ItemProcessor; @@ -53,6 +54,7 @@ public class ScriptItemProcessor implements ItemProcessor, Initializ private ScriptEvaluator scriptEvaluator; private String itemBindingVariableName = ITEM_BINDING_VARIABLE_NAME; + @Nullable @Override @SuppressWarnings("unchecked") public O process(I item) throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java index ff6bd6cecf..e31df7c387 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SingleItemPeekableItemReader.java @@ -25,6 +25,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.batch.item.PeekableItemReader; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; /** *

@@ -66,7 +67,8 @@ public void setDelegate(ItemReader delegate) { * * @see ItemReader#read() */ - @Override + @Nullable + @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (next != null) { T item = next; @@ -86,7 +88,8 @@ public T read() throws Exception, UnexpectedInputException, ParseException { * * @see PeekableItemReader#peek() */ - @Override + @Nullable + @Override public T peek() throws Exception, UnexpectedInputException, ParseException { if (next == null) { updateDelegate(executionContext); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamReader.java index 45cc5dd9aa..5afd2d7312 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/SynchronizedItemStreamReader.java @@ -21,6 +21,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -51,6 +52,7 @@ public void setDelegate(ItemStreamReader delegate) { /** * This delegates to the read method of the delegate */ + @Nullable public synchronized T read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { return this.delegate.read(); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java index dfc081aafb..a7c8d9fa41 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/validator/ValidatingItemProcessor.java @@ -17,6 +17,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -76,7 +77,8 @@ public void setFilter(boolean filter) { * @return the input item * @throws ValidationException if validation fails */ - @Override + @Nullable + @Override public T process(T item) throws ValidationException { try { validator.validate(item); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java index 9c5aaf4157..ee7598cfc5 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/xml/StaxEventItemReader.java @@ -39,6 +39,7 @@ import org.springframework.batch.item.xml.stax.FragmentEventReader; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.oxm.Unmarshaller; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -229,6 +230,7 @@ protected void doOpen() throws Exception { /** * Move to next fragment and map it to item. */ + @Nullable @Override protected T doRead() throws IOException, XMLStreamException { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemProcessorAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemProcessorAdapter.java index a8fd13f8a8..42b5db470a 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemProcessorAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemProcessorAdapter.java @@ -17,6 +17,7 @@ import javax.batch.api.chunk.ItemProcessor; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; public class ItemProcessorAdapter implements org.springframework.batch.item.ItemProcessor { @@ -28,6 +29,7 @@ public ItemProcessorAdapter(ItemProcessor processor) { this.delegate = processor; } + @Nullable @SuppressWarnings("unchecked") @Override public O process(I item) throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java index df59e91cd9..d2b4cdaf46 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java @@ -19,6 +19,7 @@ import javax.batch.api.chunk.ItemReader; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -48,6 +49,7 @@ public ItemReaderAdapter(ItemReader reader) { /* (non-Javadoc) * @see org.springframework.batch.item.ItemReader#read() */ + @Nullable @SuppressWarnings("unchecked") @Override public T read() throws Exception { diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java index 0d56704124..ae426d4ba7 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/AnnotationMethodResolver.java @@ -24,6 +24,7 @@ import org.springframework.aop.support.AopUtils; import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; @@ -66,7 +67,8 @@ public AnnotationMethodResolver(Class annotationType) { * @throws IllegalArgumentException if more than one Method has the * specified annotation */ - @Override + @Nullable + @Override public Method findMethod(Object candidate) { Assert.notNull(candidate, "candidate object must not be null"); Class targetClass = AopUtils.getTargetClass(candidate); @@ -88,7 +90,8 @@ public Method findMethod(Object candidate) { * @throws IllegalArgumentException if more than one Method has the * specified annotation */ - @Override + @Nullable + @Override public Method findMethod(final Class clazz) { Assert.notNull(clazz, "class must not be null"); final AtomicReference annotatedMethod = new AtomicReference<>(); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java index 615deabf62..c6455ddd18 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/support/SimpleMethodInvoker.java @@ -35,6 +35,7 @@ import java.util.Arrays; import org.springframework.aop.framework.Advised; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -81,7 +82,8 @@ public SimpleMethodInvoker(Object object, String methodName, Class... paramTy * org.springframework.batch.core.configuration.util.MethodInvoker#invokeMethod * (java.lang.Object[]) */ - @Override + @Nullable + @Override public Object invokeMethod(Object... args) { Class[] parameterTypes = method.getParameterTypes(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java index 001d194eed..ee05ece4bd 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/ItemReaderTests.java @@ -19,12 +19,14 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.springframework.lang.Nullable; public class ItemReaderTests { ItemReader provider = new ItemReader() { - @Override + @Nullable + @Override public String read() { return "foo"; } diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java index 285a2d4c8f..4038dd9878 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/MultiResourceItemReaderIntegrationTests.java @@ -38,6 +38,7 @@ import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import org.springframework.lang.Nullable; import org.springframework.test.util.ReflectionTestUtils; /** @@ -485,6 +486,7 @@ private static class ItemStreamReaderImpl implements ResourceAwareItemReaderItem private boolean updateCalled = false; private boolean closeCalled = false; + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { return null; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java index 7a65d29226..f7600a5182 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/mapping/PatternMatchingCompositeLineMapperTests.java @@ -28,6 +28,7 @@ import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.batch.item.file.transform.LineTokenizer; import org.springframework.batch.item.file.transform.Name; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -51,13 +52,13 @@ public void testKeyFound() throws Exception { Map tokenizers = new HashMap<>(); tokenizers.put("foo*", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return new DefaultFieldSet(new String[] { "a", "b" }); } }); tokenizers.put("bar*", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return new DefaultFieldSet(new String[] { "c", "d" }); } }); @@ -87,13 +88,13 @@ public void testMapperKeyNotFound() throws Exception { Map tokenizers = new HashMap<>(); tokenizers.put("foo*", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return new DefaultFieldSet(new String[] { "a", "b" }); } }); tokenizers.put("bar*", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return new DefaultFieldSet(new String[] { "c", "d" }); } }); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java index 2ddc1363fa..01ffa555a0 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/file/transform/PatternMatchingCompositeLineTokenizerTests.java @@ -24,6 +24,7 @@ import java.util.Map; import org.junit.Test; +import org.springframework.lang.Nullable; /** * @author Ben Hale @@ -46,7 +47,7 @@ public void testEmptyKeyMatchesAnyLine() throws Exception { map.put("*", new DelimitedLineTokenizer()); map.put("foo", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return null; } }); @@ -62,7 +63,7 @@ public void testEmptyKeyDoesNotMatchWhenAlternativeAvailable() throws Exception Map map = new LinkedHashMap<>(); map.put("*", new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return null; } }); @@ -84,7 +85,7 @@ public void testNoMatch() throws Exception { public void testMatchWithPrefix() throws Exception { tokenizer.setTokenizers(Collections.singletonMap("foo*", (LineTokenizer) new LineTokenizer() { @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { return new DefaultFieldSet(new String[] { line }); } })); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java index eecba6e5cb..4c0f14559f 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ClassifierCompositeItemProcessorTests.java @@ -24,6 +24,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.classify.PatternMatchingClassifier; import org.springframework.classify.SubclassClassifier; +import org.springframework.lang.Nullable; /** * @author Jimmy Praet @@ -35,12 +36,14 @@ public void testBasicClassifierCompositeItemProcessor() throws Exception { ClassifierCompositeItemProcessor processor = new ClassifierCompositeItemProcessor<>(); ItemProcessor fooProcessor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { return "foo: " + item; } }; ItemProcessor defaultProcessor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { return item; @@ -66,18 +69,21 @@ public void testGenericsClassifierCompositeItemProcessor() throws Exception { ClassifierCompositeItemProcessor processor = new ClassifierCompositeItemProcessor<>(); ItemProcessor intProcessor = new ItemProcessor() { + @Nullable @Override public String process(Integer item) throws Exception { return "int: " + item; } }; ItemProcessor longProcessor = new ItemProcessor() { + @Nullable @Override public StringBuffer process(Long item) throws Exception { return new StringBuffer("long: " + item); } }; ItemProcessor defaultProcessor = new ItemProcessor() { + @Nullable @Override public StringBuilder process(Number item) throws Exception { return new StringBuilder("number: " + item); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ItemCountingItemStreamItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ItemCountingItemStreamItemReaderTests.java index 0bc63dd055..113cb33dd0 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ItemCountingItemStreamItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/ItemCountingItemStreamItemReaderTests.java @@ -26,6 +26,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.batch.item.ExecutionContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -144,6 +145,7 @@ protected void doOpen() throws Exception { openCalled = true; } + @Nullable @Override protected String doRead() throws Exception { if (!items.hasNext()) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java index 98619d66d3..ac38edeff4 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SingleItemPeekableItemReaderTests.java @@ -22,6 +22,7 @@ import org.junit.Test; import org.springframework.batch.item.ExecutionContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -122,6 +123,7 @@ protected void doOpen() throws Exception { counter = 0; } + @Nullable @Override protected T doRead() throws Exception { if (counter>=list.size()) { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java index ad52124358..b67dce4629 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/SynchronizedItemStreamReaderTests.java @@ -28,6 +28,7 @@ import org.springframework.batch.item.ItemStreamReader; import org.springframework.batch.item.NonTransientResourceException; import org.springframework.batch.item.ParseException; +import org.springframework.lang.Nullable; /** * @@ -52,6 +53,7 @@ private class TestItemReader extends AbstractItemStreamItemReader imple public static final String HAS_BEEN_OPENED = "hasBeenOpened"; public static final String UPDATE_COUNT_KEY = "updateCount"; + @Nullable public Integer read() throws Exception, ParseException, NonTransientResourceException { cursor = cursor + 1; return cursor; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamReaderBuilderTests.java index ec4573b2c3..3aa5a57391 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamReaderBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/support/builder/SynchronizedItemStreamReaderBuilderTests.java @@ -27,6 +27,7 @@ import org.springframework.batch.item.ParseException; import org.springframework.batch.item.support.AbstractItemStreamItemReader; import org.springframework.batch.item.support.SynchronizedItemStreamReader; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -114,6 +115,7 @@ private class TestItemReader extends AbstractItemStreamItemReader imple public static final String UPDATE_COUNT_KEY = "updateCount"; + @Nullable public Integer read() throws Exception, ParseException, NonTransientResourceException { cursor = cursor + 1; return cursor; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java index 8b32d69bcf..d1692a1992 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/repeat/support/ChunkedRepeatTests.java @@ -25,6 +25,7 @@ import org.springframework.batch.repeat.callback.NestedRepeatCallback; import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -153,7 +154,8 @@ void increment() { ItemReader truncated = new ItemReader() { int count = 0; - @Override + @Nullable + @Override public Trade read() throws Exception { if (count++ < 2) return provider.read(); diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemProcessor.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemProcessor.java index dc2d1c9906..4bed3152ff 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemProcessor.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/async/AsyncItemProcessor.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.core.task.SyncTaskExecutor; import org.springframework.core.task.TaskExecutor; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -91,6 +92,7 @@ public void setTaskExecutor(TaskExecutor taskExecutor) { * * @see ItemProcessor#process(Object) */ + @Nullable public Future process(final I item) throws Exception { final StepExecution stepExecution = getStepExecution(); FutureTask task = new FutureTask<>(new Callable() { diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkMessageChannelItemWriter.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkMessageChannelItemWriter.java index a20f95d588..b82cd5bc86 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkMessageChannelItemWriter.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkMessageChannelItemWriter.java @@ -35,6 +35,7 @@ import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.ItemWriter; import org.springframework.integration.core.MessagingTemplate; +import org.springframework.lang.Nullable; import org.springframework.messaging.Message; import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.GenericMessage; @@ -116,6 +117,7 @@ public void beforeStep(StepExecution stepExecution) { localState.setStepExecution(stepExecution); } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { if (!(stepExecution.getStatus() == BatchStatus.COMPLETED)) { diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/BeanFactoryStepLocator.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/BeanFactoryStepLocator.java index 6d811a0019..46681d00b2 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/BeanFactoryStepLocator.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/BeanFactoryStepLocator.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -30,6 +31,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException { * Look up a bean with the provided name of type {@link Step}. * @see StepLocator#getStep(String) */ + @Nullable public Step getStep(String stepName) { return beanFactory.getBean(stepName, Step.class); } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobRepositorySupport.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobRepositorySupport.java index dedffa1951..f224d33689 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobRepositorySupport.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobRepositorySupport.java @@ -25,6 +25,7 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.JobRestartException; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -43,6 +44,7 @@ public JobExecution createJobExecution(String jobName, JobParameters jobParamete /* (non-Javadoc) * @see org.springframework.batch.core.repository.JobRepository#getLastStepExecution(org.springframework.batch.core.JobInstance, org.springframework.batch.core.Step) */ + @Nullable public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; } @@ -88,6 +90,7 @@ public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) /* (non-Javadoc) * @see org.springframework.batch.core.repository.JobRepository#getLastJobExecution(java.lang.String, org.springframework.batch.core.JobParameters) */ + @Nullable public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) { return null; } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobSupport.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobSupport.java index 40b637289f..c480dd562c 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobSupport.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/JobSupport.java @@ -5,6 +5,7 @@ import org.springframework.batch.core.JobParametersIncrementer; import org.springframework.batch.core.JobParametersValidator; import org.springframework.batch.core.job.DefaultJobParametersValidator; +import org.springframework.lang.Nullable; public class JobSupport implements Job { @@ -25,6 +26,7 @@ public boolean isRestartable() { return false; } + @Nullable public JobParametersIncrementer getJobParametersIncrementer() { return null; } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorTests.java index e06ae00fd2..9af4d83f51 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/async/AsyncItemProcessorTests.java @@ -30,12 +30,14 @@ import org.springframework.batch.test.MetaDataInstanceFactory; import org.springframework.batch.test.StepScopeTestUtils; import org.springframework.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; public class AsyncItemProcessorTests { private AsyncItemProcessor processor = new AsyncItemProcessor<>(); private ItemProcessor delegate = new ItemProcessor() { + @Nullable public String process(String item) throws Exception { return item + item; }; @@ -56,6 +58,7 @@ public void testExecution() throws Exception { @Test public void testExecutionInStepScope() throws Exception { delegate = new ItemProcessor() { + @Nullable public String process(String item) throws Exception { StepContext context = StepSynchronizationManager.getContext(); assertTrue(context != null && context.getStepExecution() != null); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java index 0efbc47197..0304cbe262 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/RemoteChunkingManagerStepBuilderTest.java @@ -51,6 +51,7 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.core.MessagingTemplate; +import org.springframework.lang.Nullable; import org.springframework.messaging.PollableChannel; import org.springframework.retry.RetryListener; import org.springframework.retry.backoff.NoBackOffPolicy; @@ -271,6 +272,7 @@ public void testSetters() throws Exception { int count = 0; List items = Arrays.asList("a", "b", "c", "d", "d", "e", "f", "g", "h", "i"); + @Nullable @Override public String read() throws Exception { System.out.println(">> count == " + count); diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemReader.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemReader.java index 132ff0841d..e3c0be7e65 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemReader.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/chunk/TestItemReader.java @@ -8,6 +8,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ParseException; import org.springframework.batch.item.UnexpectedInputException; +import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; @Component @@ -39,6 +40,7 @@ public void setItems(List items) { this.items = items; } + @Nullable public T read() throws Exception, UnexpectedInputException, ParseException { if (count>=items.size()) { diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java index 282078bec6..8f59844dc9 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/config/xml/RemoteChunkingParserTests.java @@ -34,6 +34,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.config.ServiceActivatorFactoryBean; import org.springframework.integration.test.util.TestUtils; +import org.springframework.lang.Nullable; import org.springframework.messaging.MessageChannel; import static org.junit.Assert.assertNotNull; @@ -497,6 +498,7 @@ public void write(List items) throws Exception { } private static class Processor implements ItemProcessor { + @Nullable @Override public String process(String item) throws Exception { return item; diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/ExampleItemReader.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/ExampleItemReader.java index c9b1c299d8..3509c78c82 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/ExampleItemReader.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/ExampleItemReader.java @@ -6,6 +6,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemStreamException; +import org.springframework.lang.Nullable; /** * {@link ItemReader} with hard-coded input data. @@ -23,6 +24,7 @@ public class ExampleItemReader implements ItemReader, ItemStream { /** * Reads next record from input */ + @Nullable public String read() throws Exception { if (index >= input.length) { return null; diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/step/TestTasklet.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/step/TestTasklet.java index 8fd02affaf..7c84c7ab71 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/step/TestTasklet.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/step/TestTasklet.java @@ -19,6 +19,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -32,6 +33,7 @@ public void setFail(boolean fail) { this.fail = fail; } + @Nullable public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (fail) { throw new IllegalStateException("Planned Tasklet failure"); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java index 545fca9dfb..a0dcb8ea3c 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/InfiniteLoopReader.java @@ -17,6 +17,7 @@ package org.springframework.batch.sample.common; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; /** * ItemReader implementation that will continually return a new object. It's @@ -27,6 +28,7 @@ */ public class InfiniteLoopReader implements ItemReader { + @Nullable @Override public Object read() throws Exception { return new Object(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java index ab81d65404..e077894661 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemProcessor.java @@ -22,6 +22,7 @@ import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -57,6 +58,7 @@ public void afterPropertiesSet() throws Exception { * Use the technical identifier to mark the input row as processed and * return unwrapped item. */ + @Nullable @Override public T process(ProcessIndicatorItemWrapper wrapper) throws Exception { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java index 7a9cd068ae..1be359cfca 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemReader.java @@ -36,6 +36,7 @@ import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.SerializationUtils; @@ -96,6 +97,7 @@ public Long mapRow(ResultSet rs, int rowNum) throws SQLException { } + @Nullable @Override public ProcessIndicatorItemWrapper read() { if (!initialized) { @@ -126,6 +128,7 @@ public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return new ProcessIndicatorItemWrapper<>(id, result); } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java index f318895993..bd4e8ede12 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/common/StagingItemWriter.java @@ -28,6 +28,7 @@ import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.support.JdbcDaoSupport; import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.SerializationUtils; @@ -101,6 +102,7 @@ public void setValues(PreparedStatement ps, int i) throws SQLException { * org.springframework.batch.core.domain.StepListener#afterStep(StepExecution * ) */ + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java index 6c9c9cf9f5..ff5049e7c5 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/mail/internal/UserMailItemProcessor.java @@ -19,6 +19,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.sample.domain.mail.User; +import org.springframework.lang.Nullable; import org.springframework.mail.SimpleMailMessage; /** @@ -33,7 +34,8 @@ public class UserMailItemProcessor implements /** * @see org.springframework.batch.item.ItemProcessor#process(java.lang.Object) */ - @Override + @Nullable + @Override public SimpleMailMessage process( User user ) throws Exception { SimpleMailMessage message = new SimpleMailMessage(); message.setTo( user.getEmail() ); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java index fe8bbff276..d2c47f6a7d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/multiline/AggregateItemReader.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; /** * An {@link ItemReader} that delivers a list as its item, storing up objects @@ -51,6 +52,7 @@ public class AggregateItemReader implements ItemReader> { * * @see org.springframework.batch.item.ItemReader#read() */ + @Nullable @Override public List read() throws Exception { ResultHolder holder = new ResultHolder(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java index 552db3f74f..e54a71544f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/OrderItemReader.java @@ -29,6 +29,7 @@ import org.springframework.batch.sample.domain.order.LineItem; import org.springframework.batch.sample.domain.order.Order; import org.springframework.batch.sample.domain.order.ShippingInfo; +import org.springframework.lang.Nullable; /** * @author peter.zozom @@ -58,6 +59,7 @@ public class OrderItemReader implements ItemReader { /** * @see org.springframework.batch.item.ItemReader#read() */ + @Nullable @Override public Order read() throws Exception { recordFinished = false; diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizer.java index d67ed3d6af..e9166fa68f 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizer.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizer.java @@ -20,6 +20,7 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.batch.item.file.transform.LineTokenizer; +import org.springframework.lang.Nullable; /** * Composite {@link LineTokenizer} that delegates the tokenization of a line to one of two potential @@ -40,7 +41,7 @@ public class CompositeCustomerUpdateLineTokenizer extends StepExecutionListenerS * @see org.springframework.batch.item.file.transform.LineTokenizer#tokenize(java.lang.String) */ @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { if(line.charAt(0) == 'F'){ //line starts with F, so the footer tokenizer should tokenize it. diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessor.java index aa80eed3f5..fc1cd2264d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/CustomerUpdateProcessor.java @@ -19,6 +19,7 @@ import static org.springframework.batch.sample.domain.trade.CustomerOperation.*; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; /** * @author Lucas Ward @@ -29,6 +30,7 @@ public class CustomerUpdateProcessor implements ItemProcessor { public static final BigDecimal FIXED_AMOUNT = new BigDecimal("5"); + @Nullable @Override public CustomerCredit process(CustomerCredit item) throws Exception { return item.increaseCreditBy(FIXED_AMOUNT); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/GeneratingTradeItemReader.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/GeneratingTradeItemReader.java index 1e368f1a70..1a2082a830 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/GeneratingTradeItemReader.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/GeneratingTradeItemReader.java @@ -20,6 +20,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.sample.domain.trade.Trade; +import org.springframework.lang.Nullable; /** * Generates configurable number of {@link Trade} items. @@ -32,6 +33,7 @@ public class GeneratingTradeItemReader implements ItemReader { private int counter = 0; + @Nullable @Override public Trade read() throws Exception { if (counter < limit) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessor.java index 565927842f..8d1af71d9d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/trade/internal/TradeProcessor.java @@ -19,6 +19,7 @@ import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.validator.ValidationException; import org.springframework.batch.sample.domain.trade.Trade; +import org.springframework.lang.Nullable; /** * Processes the Trade - throwing validation errors if necessary. @@ -40,6 +41,7 @@ public void setValidationFailure(int failure) { this.failure = failure; } + @Nullable @Override public Trade process(Trade item) throws Exception { if ((failedItem == null && index++ == failure) || (failedItem != null && failedItem.equals(item))) { diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jsr352/JsrSampleTasklet.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jsr352/JsrSampleTasklet.java index 2105c06ce7..8acde22157 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/jsr352/JsrSampleTasklet.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/jsr352/JsrSampleTasklet.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; import javax.batch.api.BatchProperty; import javax.inject.Inject; @@ -40,6 +41,7 @@ public class JsrSampleTasklet implements Tasklet { @BatchProperty private String remoteServiceURL; + @Nullable @Override public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { LOG.info("Calling remote service at: " + remoteServiceURL); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/GeneratingTradeResettingListener.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/GeneratingTradeResettingListener.java index 8e4e68dbe3..ed62f02bfd 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/GeneratingTradeResettingListener.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/GeneratingTradeResettingListener.java @@ -20,6 +20,7 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; import org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader; import org.springframework.beans.factory.InitializingBean; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -33,6 +34,7 @@ public class GeneratingTradeResettingListener extends StepExecutionListenerSuppo private GeneratingTradeItemReader reader; + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { this.reader.resetCounter(); diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/LimitDecider.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/LimitDecider.java index 2c71a43474..d6496e6315 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/LimitDecider.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/loop/LimitDecider.java @@ -19,6 +19,7 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.JobExecutionDecider; +import org.springframework.lang.Nullable; /** * This decider will return "CONTINUE" until the limit it reached, at which @@ -34,7 +35,7 @@ public class LimitDecider implements JobExecutionDecider { private int limit = 1; @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { if (++count >= limit) { return new FlowExecutionStatus("COMPLETED"); } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java index 544bc11de7..9a35e32e6d 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java @@ -16,6 +16,7 @@ package org.springframework.batch.sample.rabbitmq.processor; import org.springframework.batch.item.ItemProcessor; +import org.springframework.lang.Nullable; import java.util.Date; @@ -26,7 +27,8 @@ */ public class MessageProcessor implements ItemProcessor { - @Override + @Nullable + @Override public String process(String message) throws Exception { return "Message: \"" + message + "\" processed on: " + new Date(); } diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ExceptionThrowingItemReaderProxy.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ExceptionThrowingItemReaderProxy.java index 3e26acac60..4c2fc41048 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ExceptionThrowingItemReaderProxy.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/support/ExceptionThrowingItemReaderProxy.java @@ -18,6 +18,7 @@ import org.springframework.batch.core.UnexpectedJobExecutionException; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; /** * Hacked {@link ItemReader} that throws exception on a given record number @@ -43,6 +44,7 @@ public void setThrowExceptionOnRecordNumber(int throwExceptionOnRecordNumber) { this.throwExceptionOnRecordNumber = throwExceptionOnRecordNumber; } + @Nullable @Override public T read() throws Exception { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java index 54c559b1e6..192b2128bd 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/CustomItemReaderTests.java @@ -27,6 +27,7 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.ItemStreamException; +import org.springframework.lang.Nullable; /** * Unit test class that was used as part of the Reference Documentation. I'm only including it in the @@ -85,6 +86,7 @@ public CustomItemReader(List items) { this.items = items; } + @Nullable @Override public T read() throws Exception { if (currentIndex < items.size()) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java index eb1d00e7cb..12489f8ca4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/ErrorLogTasklet.java @@ -26,6 +26,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -38,6 +39,7 @@ public class ErrorLogTasklet implements Tasklet, StepExecutionListener { private StepExecution stepExecution; private String stepName; + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Assert.notNull(this.stepName, "Step name not set. Either this class was not registered as a listener " @@ -74,6 +76,7 @@ public void beforeStep(StepExecution stepExecution) { stepExecution.getJobExecution().getExecutionContext().remove("stepName"); } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java index 5ffc100186..0acc01c0e4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/common/SkipCheckingDecider.java @@ -20,11 +20,12 @@ import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.flow.FlowExecutionStatus; import org.springframework.batch.core.job.flow.JobExecutionDecider; +import org.springframework.lang.Nullable; public class SkipCheckingDecider implements JobExecutionDecider { - + @Override - public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) { if (!stepExecution.getExitStatus().getExitCode().equals( ExitStatus.FAILED.getExitCode()) && stepExecution.getSkipCount() > 0) { @@ -33,4 +34,4 @@ public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepE return new FlowExecutionStatus(ExitStatus.COMPLETED.getExitCode()); } } -} +} diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java index a9d9a5405e..54a3ed1d1a 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/multiline/AggregateItemReaderTests.java @@ -21,6 +21,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.batch.item.ItemReader; +import org.springframework.lang.Nullable; public class AggregateItemReaderTests { private ItemReader> input; @@ -31,6 +32,7 @@ public void setUp() { input = new ItemReader>() { private int count = 0; + @Nullable @Override public AggregateItem read() { switch (count++) { diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java index 38935c1ff5..c6cb017935 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/domain/trade/CompositeCustomerUpdateLineTokenizerTests.java @@ -22,6 +22,7 @@ import org.springframework.batch.item.file.transform.DefaultFieldSet; import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.batch.item.file.transform.LineTokenizer; +import org.springframework.lang.Nullable; /** * @author Lucas Ward @@ -80,7 +81,7 @@ public StubLineTokenizer(FieldSet fieldSetToReturn) { } @Override - public FieldSet tokenize(String line) { + public FieldSet tokenize(@Nullable String line) { this.tokenizedLine = line; return fieldSetToReturn; } diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java index 48569970ca..2d4066e9e2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/internal/MultiLineTradeItemReader.java @@ -23,6 +23,7 @@ import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.batch.sample.domain.trade.Trade; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** @@ -35,6 +36,7 @@ public class MultiLineTradeItemReader implements ItemReader, ItemStream { /** * @see org.springframework.batch.item.ItemReader#read() */ + @Nullable @Override public Trade read() throws Exception { Trade t = null; diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java index 4f00a6887b..253ef770b4 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/quartz/JobLauncherDetailsTests.java @@ -42,6 +42,7 @@ import org.springframework.batch.core.launch.NoSuchJobException; import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; import org.springframework.batch.core.repository.JobRestartException; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -65,7 +66,7 @@ public JobExecution run(org.springframework.batch.core.Job job, JobParameters jo details.setJobLocator(new JobLocator() { @Override - public org.springframework.batch.core.Job getJob(String name) throws NoSuchJobException { + public org.springframework.batch.core.Job getJob(@Nullable String name) throws NoSuchJobException { list.add(name); return new StubJob("foo"); } @@ -173,6 +174,7 @@ public StubJob(String name) { public void execute(JobExecution execution) { } + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java index 30b9e0074c..af8be95766 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java @@ -33,6 +33,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; import static org.junit.Assert.assertEquals; @@ -65,6 +66,7 @@ public static class TestJobConfiguration { @Bean public Step step() { return stepBuilderFactory.get("step1").tasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { return null; diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java index 69101be962..b1a6fc87de 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobRepositoryTestUtilsTests.java @@ -33,6 +33,7 @@ import org.springframework.batch.core.repository.JobRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.jdbc.JdbcTestUtils; @@ -135,7 +136,7 @@ public void testCreateJobExecutionsWithIncrementer() throws Exception { utils = new JobRepositoryTestUtils(jobRepository, dataSource); utils.setJobParametersIncrementer(new JobParametersIncrementer() { @Override - public JobParameters getNext(JobParameters parameters) { + public JobParameters getNext(@Nullable JobParameters parameters) { return new JobParametersBuilder().addString("foo","bar").toJobParameters(); } }); diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java index 89f64b68b4..aba1ed31a2 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/StepScopeAnnotatedListenerIntegrationTests.java @@ -43,6 +43,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -77,6 +78,7 @@ public ExitStatus exploitState(StepExecution stepExecution) { return stepExecution.getExitStatus(); } + @Nullable @Override public String read() throws Exception { this.list.add("some stateful reading information"); @@ -136,6 +138,7 @@ public StatefulItemReader reader() { public ItemProcessor processor() { return new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { return item; diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java index a86a82e387..e164bdf65a 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/LoggingTasklet.java @@ -21,6 +21,7 @@ import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; +import org.springframework.lang.Nullable; public class LoggingTasklet implements Tasklet { @@ -32,7 +33,8 @@ public LoggingTasklet(int id) { this.id = id; } - @Override + @Nullable + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { logger.info("tasklet executing: id=" + id); return RepeatStatus.FINISHED; diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java index 743c7b2549..b08b51f06d 100755 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/sample/SampleTasklet.java @@ -25,6 +25,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.lang.Nullable; public class SampleTasklet implements Tasklet { @@ -41,7 +42,8 @@ public SampleTasklet(int id) { this.id = id; } - @Override + @Nullable + @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { this.jdbcTemplate.update("insert into TESTS(ID, NAME) values (?, 'SampleTasklet" + id + "')", id);