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 001035005..e801bf37f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 d88aca3ef..037ea7ee3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ import org.springframework.batch.core.StepContribution; 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 18953da6d..e7c089855 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ import org.springframework.jdbc.datasource.embedded.ConnectionProperties; 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 class ConcurrentTransactionTests { 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 class ConcurrentTransactionTests { }).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 class ConcurrentTransactionTests { 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 class ConcurrentTransactionTests { 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 a421cfcd3..cbbb2a9cc 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 @@ -1,5 +1,5 @@ /* - * Copyright 2005-2014 the original author or authors. + * Copyright 2005-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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,8 +29,9 @@ import org.springframework.ldap.core.LdapAttributes; */ public class MyMapper implements RecordMapper { + @Nullable public LdapAttributes mapRecord(LdapAttributes attributes) { return attributes; } -} \ No newline at end of file +} 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 2a9e0bca7..aef6c5bb1 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 @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.item.ldif.builder.MappingLdifReaderBuilder; 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 class MappingLdifReaderBuilderTests { } 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 0aa95c36c..b8c3284a0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.core.Step; 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 class JobSupport implements BeanNameAware, Job { /* (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 a3e29216a..0e5f5fd00 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import org.springframework.batch.item.UnexpectedInputException; 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 class FaultTolerantStepFactoryBeanIntegrationTests { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -273,6 +275,7 @@ public class FaultTolerantStepFactoryBeanIntegrationTests { 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 eb5bba5c3..f5603daa7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import org.springframework.batch.item.UnexpectedInputException; 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 class FaultTolerantStepFactoryBeanRollbackIntegrationTests { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -305,6 +307,7 @@ public class FaultTolerantStepFactoryBeanRollbackIntegrationTests { 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 bf74493b2..50d6aa74c 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.ItemReader; 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 class FaultTolerantStepIntegrationTests { 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 474ef209d..9fc279d25 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.batch.item.ItemProcessor; 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 class MapRepositoryFaultTolerantStepFactoryBeanRollbackTests { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception { counter++; @@ -236,6 +238,7 @@ public class MapRepositoryFaultTolerantStepFactoryBeanRollbackTests { 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 18ab1ff3b..669b44142 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2014 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import org.springframework.batch.item.ItemWriter; 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 class MapRepositoryFaultTolerantStepFactoryBeanTests { counter = -1; } + @Nullable @Override public synchronized String read() throws Exception, UnexpectedInputException, ParseException { counter++; @@ -226,6 +228,7 @@ public class MapRepositoryFaultTolerantStepFactoryBeanTests { 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 8c16aef79..7e59b9bdb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,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.context.support.ClassPathXmlApplicationContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -87,6 +88,7 @@ public class SplitJobMapRepositoryIntegrationTests { 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 55daded09..590aaa463 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.core.configuration.DuplicateJobException; 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 class MapJobRegistry implements JobRegistry { } @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 9c5c7b79c..81a1d9c33 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 class SimpleJobExplorer implements JobExplorer { * (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 class SimpleJobExplorer implements JobExplorer { * 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 class SimpleJobExplorer implements JobExplorer { * 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 class SimpleJobExplorer implements JobExplorer { * 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 class SimpleJobExplorer implements JobExplorer { * 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 808f1c450..d099f5d7d 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 @@ InitializingBean { * @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 53b191966..403b41a09 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.core.Step; 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 class SimpleJob extends AbstractJob { * @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 fff74e1df..4455d6e55 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.core.job.AbstractJob; 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 class FlowJob extends AbstractJob { /** * {@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 8e2e9bd83..33850d2e8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.core.job.flow.State; 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 class StepState extends AbstractState implements StepLocator, StepHolder /* (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 6933932b7..f4294df41 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import javax.batch.operations.BatchRuntimeException; 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 class StepListenerAdapter implements StepExecutionListener { } } + @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 05654ba69..a5adb93c3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.batch.core.partition.support.StepExecutionAggregator; 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 class PartitionStep extends org.springframework.batch.core.partition.supp /* (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 e41dda27a..1bf71cfbd 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.batch.core.StepContribution; 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 class BatchletAdapter implements StoppableTasklet { 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 d258a0476..64fc10717 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.core.ExitStatus; 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 class CompositeStepExecutionListener implements 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 7caae99b3..da6af4529 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.core.StepExecution; 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 5f82d7264..4866d517a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,6 +170,7 @@ ItemProcessListener, ItemWriteListener, SkipListener, RetryReadLi /** * @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 04f037e71..49bd5a282 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.core.listener; 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 9ab7d72e3..9482c9b7f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ ItemReadListener, ItemProcessListener, ItemWriteListener, SkipListene /* (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 15f2a7ab3..327d5a131 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 class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements } } + @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 e72cf3f31..066c97184 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 class MapJobExecutionDao implements JobExecutionDao { } } + @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 ce09fce6b..1870e9191 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2018 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 608ba7c79..72907c137 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 cd1246738..ad1e94184 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.core.step; 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 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; */ 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 fcee1d89d..5aabc201b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.core.StepContribution; 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 class ChunkOrientedTasklet implements Tasklet { 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 1ee2280e3..65e7b2278 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.core.StepContribution; 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 class CallableTaskletAdapter implements Tasklet, InitializingBean { * 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 edc0ffe81..a90878455 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.springframework.batch.core.StepContribution; 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 96f0c1238..a1be7bcf6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.batch.repeat.RepeatStatus; 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 f1cd7b7bc..30d8497a3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired; 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 @@ public class JobBuilderConfigurationTests { @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 class JobBuilderConfigurationTests { 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 8b7bc06ba..8a1ff3b74 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext 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 @@ public class JobLoaderConfigurationTests { @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 class JobLoaderConfigurationTests { @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 4325e1b1d..dc3ec0498 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.context.annotation.ImportResource; 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 class JobScopeConfigurationTests { 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 9df722f7a..501be9203 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ import org.springframework.context.annotation.Bean; 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 class MapJobRepositoryConfigurationTests { @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 d27635ed6..2af2dc03b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.context.annotation.ImportResource; 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 @@ public class StepScopeConfigurationTests { 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 9956f4782..c955d6a8b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.batch.core.step.NoSuchStepException; 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 class DefaultJobLoaderTests { public void execute(JobExecution execution) { } - @Override + @Nullable + @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; } @@ -264,7 +266,8 @@ public class DefaultJobLoaderTests { 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 8e206d962..70bab1020 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; 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 class DecisionJobParserTests { 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 795ae01c1..04f6b8a40 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.batch.core.ExitStatus; 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 class DefaultUnknownJobParserTests extends AbstractJobParserTests { } 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 99c83fb30..b36c6de45 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 @@ import org.springframework.batch.item.ItemProcessor; */ 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 f02754a60..2db54248c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml; 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 @@ import org.springframework.batch.item.UnexpectedInputException; */ 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 485f265aa..fd2ebb050 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteExcep 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 class DummyJobRepository implements JobRepository, BeanNameAware { 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 43d6a03c9..aefe4480b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import org.springframework.batch.core.StepContribution; 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 @@ import org.springframework.batch.repeat.RepeatStatus; */ 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 27d1595bf..cfd414039 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml; 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 @@ import org.springframework.batch.repeat.RepeatStatus; */ 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 c7808e55e..9bc05c7e7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.batch.core.repository.JobRepository; 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 class FlowStepParserTests { 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 a0df6ca60..aac3cf570 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.core.configuration.xml; 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 951441bb5..bdb00fb61 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.batch.core.listener.StepExecutionListenerSupport; 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 class NameStoringTasklet extends StepExecutionListenerSupport implements 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 7855cc3e3..52cce6596 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.batch.core.ExitStatus; 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 class NextAttributeUnknownJobParserTests extends AbstractJobParserTests { } 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 caba40b80..2d6682c9f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +19,12 @@ import org.springframework.batch.core.ExitStatus; 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 2e861c265..33aa60235 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.batch.core.repository.JobRepository; 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 class PartitionStepWithFlowParserTests { 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 bf23c0b10..a926b19c4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.batch.core.JobExecution; 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 class StopJobParserTests extends AbstractJobParserTests { 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 6420630bf..e60356ccb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,11 @@ package org.springframework.batch.core.configuration.xml; 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 bc54f4082..90250f84a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,12 @@ package org.springframework.batch.core.configuration.xml; 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 2dd9d97c1..4fa621acd 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,11 @@ import org.springframework.batch.core.ExitStatus; 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 ea1d1a30e..71010c67e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 356ed0414..77c504774 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.item.ExecutionContext; 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 class TestReader extends AbstractTestComponent implements ItemStreamReade 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 bee5e8484..c5618b3ce 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ import org.springframework.batch.core.StepContribution; 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 0978a4f5f..ac06c9de1 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,12 @@ import java.util.Properties; 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 class JobParametersConverterSupport implements JobParametersConverter { * @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 5b20c5a2e..3fcc0ddef 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; 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 class MapJobExplorerIntegrationTests { 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 4ea6b8bda..fae9c3aef 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.core.StepExecution; 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 class ExtendedAbstractJobTests { 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 class ExtendedAbstractJobTests { 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 9bce003f2..3e5bf81f6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.core.UnexpectedJobExecutionException; 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 class JobSupport implements BeanNameAware, Job, StepLocator { * * @see org.springframework.batch.core.Job#getJobParametersIncrementer() */ + @Nullable @Override public JobParametersIncrementer getJobParametersIncrementer() { return null; @@ -190,6 +192,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator { 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 599ff9684..3ed08c5c2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,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.core.task.SimpleAsyncTaskExecutor; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -168,7 +169,7 @@ public class FlowJobBuilderTests { 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 69d486230..d253fc54a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.batch.core.repository.JobRepository; 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 class FlowJobTests { 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 class FlowJobTests { 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 34e13531c..a97ec37a3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.core.job.flow.FlowExecution; 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 class JobFlowExecutorSupport implements FlowExecutor { 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 20a76bfff..c27e95b1e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.core.JobExecution; 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 class ItemListenerParsingTests { } @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 d8da4bd59..190db67a0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.springframework.batch.core.jsr.AbstractJsrTestCase; 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 class ItemSkipParsingTests extends AbstractJsrTestCase { public static class SkipErrorGeneratingReader implements ItemReader { private static int count = 0; + @Nullable @Override public String read() throws Exception { count++; @@ -104,6 +106,7 @@ public class ItemSkipParsingTests extends AbstractJsrTestCase { 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 8c6a9f77b..0bc24eadb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import org.springframework.batch.core.jsr.AbstractJsrTestCase; 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 class JobPropertyTests extends AbstractJsrTestCase { @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 d889a4538..40471eb94 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.core.StepExecution; 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 class StepListenerParsingTests { 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 095411f57..38f7b1aea 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ import org.springframework.batch.core.repository.JobRepository; 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 class JsrFlowJobTests { 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 03b6f84a4..621abf291 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.core.job.flow.StateSupport; 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 class JsrFlowTests extends SimpleFlowTests { 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 41fd29604..72214df7b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.batch.item.ItemProcessor; 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 class JsrChunkProcessorTests { super(list); } + @Nullable @Override public String read() { count++; @@ -330,6 +332,7 @@ public class JsrChunkProcessorTests { protected int failCount = -1; protected boolean filter = false; + @Nullable @Override public String process(String item) throws Exception { count++; @@ -393,7 +396,7 @@ public class JsrChunkProcessorTests { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { afterProcess++; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrFaultTolerantChunkProcessorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrFaultTolerantChunkProcessorTests.java index 97f4b9469..95c530af0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrFaultTolerantChunkProcessorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/step/item/JsrFaultTolerantChunkProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ import org.springframework.batch.item.ItemProcessor; 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 JsrFaultTolerantChunkProcessorTests { @@ -499,6 +500,7 @@ public class JsrFaultTolerantChunkProcessorTests { super(list); } + @Nullable @Override public String read() { count++; @@ -516,6 +518,7 @@ public class JsrFaultTolerantChunkProcessorTests { protected int failCount = -1; protected boolean filter = false; + @Nullable @Override public String process(String item) throws Exception { count++; @@ -583,7 +586,7 @@ public class JsrFaultTolerantChunkProcessorTests { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { afterProcess++; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java index 49b88ea03..8b068fc2b 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/launch/support/CommandLineJobRunnerTests.java @@ -46,6 +46,7 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep import org.springframework.batch.core.step.JobRepositorySupport; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.Nullable; import org.springframework.util.ClassUtils; import static org.junit.Assert.assertEquals; @@ -456,12 +457,13 @@ public class CommandLineJobRunnerTests { static JobParameters jobParameters = new JobParameters(); @Override - public Set 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 @@ public class CommandLineJobRunnerTests { 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 class CommandLineJobRunnerTests { 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 class CommandLineJobRunnerTests { } @Override - public int getJobInstanceCount(String jobName) + public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException { int count = 0; @@ -569,13 +575,13 @@ public class CommandLineJobRunnerTests { 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 8d636ed81..9eae8ca5d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ import org.springframework.batch.core.step.tasklet.StoppableTasklet; 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 class SimpleJobOperatorTests { 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 class SimpleJobOperatorTests { 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 class SimpleJobOperatorTests { 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 @@ public class SimpleJobOperatorTests { 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 e7254b7fd..41008f2fa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2012 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,12 @@ package org.springframework.batch.core.launch.support; 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 ae2a9e938..7aad3ea6e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.batch.core.ExitStatus; 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 class CompositeStepExecutionListenerTests extends TestCase { 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 class CompositeStepExecutionListenerTests extends TestCase { return ExitStatus.FAILED; } }, new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("continue"); @@ -70,6 +73,7 @@ public class CompositeStepExecutionListenerTests extends TestCase { 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 ec142f5d5..c79ed1c14 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.batch.item.support.ListItemReader; 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 class ItemListenerErrorTests { private boolean goingToFail = false; + @Nullable @Override public String process(String item) throws Exception { if(goingToFail) { @@ -210,6 +212,7 @@ public class ItemListenerErrorTests { private int count = 0; + @Nullable @Override public String read() throws Exception { count++; @@ -267,7 +270,7 @@ public class ItemListenerErrorTests { } @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 b0aaa1db6..2996d17da 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.batch.core.annotation.BeforeProcess; 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 class MulticasterBatchListenerTests { 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 class MulticasterBatchListenerTests { 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 class MulticasterBatchListenerTests { * 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 82ae92e2d..9bd1a3dd7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ import org.springframework.batch.core.configuration.xml.AbstractTestComponent; 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 @@ public class StepListenerFactoryBeanTests { int callcount = 0; + @Nullable @Override @AfterStep public ExitStatus afterStep(StepExecution stepExecution) { @@ -397,6 +399,7 @@ public class StepListenerFactoryBeanTests { 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 da5306e46..a2e071889 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2013 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.item.ExecutionContext; 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 class ExampleItemReader extends AbstractItemStreamItemReader { /** * 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 d4fae4a30..410ac1774 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.batch.item.ItemWriter; 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 class OptimisticLockingFailureTests { } 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 a1e53b9e1..d69fce599 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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.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 class TablePrefixTests { 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 8fb1170c9..1cb4cbb0d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.core.JobParametersIncrementer; 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 class TestJob implements Job { 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 55339d9f8..6ef540fdc 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.core.JobInstance; 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 class JobRepositorySupport implements JobRepository { public void update(JobInstance job) { } + @Nullable @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; @@ -90,6 +92,7 @@ public class JobRepositorySupport implements JobRepository { 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 e95ad59c4..f6b81e7b8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2013 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.batch.core.JobParameters; 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 @@ public class NonAbstractStepTests { 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 efbdef930..1c071a367 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,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.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 class RestartInPriorStepTests { public static class DecidingTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { @@ -93,7 +95,7 @@ public class RestartInPriorStepTests { @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 275b7be29..6c497ec7b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,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.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 class RestartLoopTests { } 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 e5606eed1..58dc347d0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ import org.springframework.context.support.GenericApplicationContext; 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 class RegisterMultiListenerTests { private int count = 0; + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException, @@ -310,6 +312,7 @@ public class RegisterMultiListenerTests { 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 f0e8402a8..81f2f073d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +47,7 @@ import org.springframework.batch.item.support.ListItemReader; 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 class StepBuilderTests { 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 60b1c86d9..bf9ed43ab 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.batch.item.ItemStreamException; 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 class ChunkMonitorTests { @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 class ChunkMonitorTests { 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 3f866a30b..89bdfbb3d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,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.batch.support.transaction.TransactionAwareProxyFactory; +import org.springframework.lang.Nullable; /** * @author Dan Garrette @@ -56,6 +57,7 @@ public class ExceptionThrowingTaskletStub implements Tasklet { 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 8979b3cfa..7f5502513 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.batch.item.ItemWriter; 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 class FaultTolerantChunkProcessorTests { @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 class FaultTolerantChunkProcessorTests { 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 class FaultTolerantChunkProcessorTests { 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 class FaultTolerantChunkProcessorTests { 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 class FaultTolerantChunkProcessorTests { @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 class FaultTolerantChunkProcessorTests { 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 class FaultTolerantChunkProcessorTests { 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 35fff686a..9daf80a9e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 the original author or authors. + * Copyright 2010-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.batch.item.ParseException; 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 class FaultTolerantChunkProviderTests { @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 e5700a352..7c20b5e0c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ import org.springframework.batch.item.support.AbstractItemCountingItemStreamItem 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 class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public Integer process(String item) throws Exception { processed.add(item); @@ -205,6 +207,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processed.add(item); @@ -253,6 +256,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { }; ItemProcessor processor = new ItemProcessor() { + @Nullable @Override public String process(String item) throws Exception { processed.add(item); @@ -290,6 +294,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { 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 @@ public class FaultTolerantStepFactoryBeanRetryTests { "c", "d", "e", "f")); } + @Nullable @Override protected String doRead() throws Exception { return reader.read(); @@ -394,6 +400,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { 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 class FaultTolerantStepFactoryBeanRetryTests { 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 class FaultTolerantStepFactoryBeanRetryTests { 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 class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -612,6 +622,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(1); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -665,6 +676,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { factory.setSkipLimit(0); ItemReader provider = new ListItemReader( Arrays.asList("b")) { + @Nullable @Override public String read() { String item = super.read(); @@ -715,6 +727,7 @@ public class FaultTolerantStepFactoryBeanRetryTests { // 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 765b8094a..b64fd274f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2018 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,6 +66,7 @@ import org.springframework.batch.item.WriterNotOpenException; 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 class FaultTolerantStepFactoryBeanTests { } @Override - public void afterProcess(String item, String result) { + public void afterProcess(String item, @Nullable String result) { listenerCalls.add(3); } @@ -863,6 +864,7 @@ public class FaultTolerantStepFactoryBeanTests { opened = true; } + @Nullable @Override public String read() { return null; @@ -901,6 +903,7 @@ public class FaultTolerantStepFactoryBeanTests { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -922,6 +925,7 @@ public class FaultTolerantStepFactoryBeanTests { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -963,6 +967,7 @@ public class FaultTolerantStepFactoryBeanTests { public void update(ExecutionContext executionContext) throws ItemStreamException { } + @Nullable @Override public String read() throws Exception, UnexpectedInputException, ParseException { return null; @@ -997,7 +1002,7 @@ public class FaultTolerantStepFactoryBeanTests { 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 5548462db..4f9a1936b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2013 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,11 +30,13 @@ import org.springframework.batch.core.StepContribution; 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 69c7c97c0..3e3c3250b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ import org.springframework.batch.repeat.exception.SimpleLimitExceptionHandler; 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 @@ public class SimpleStepFactoryBeanTests { public void write(List items) throws Exception { } + @Nullable @Override public String process(String item) throws Exception { return item; @@ -413,7 +415,7 @@ public class SimpleStepFactoryBeanTests { } @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 ec97c30a0..dc83aea49 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.List; 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 class SkipProcessorStub extends AbstractExceptionThrowingItemHandlerSt 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 bad4efe3c..9aedbf1ad 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.List; 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 class SkipReaderStub extends AbstractExceptionThrowingItemHandlerStub< 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 9ac4ca121..96f0e29ce 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ import org.springframework.batch.item.ItemStreamException; 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 class TaskletStepExceptionTests { @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 class TaskletStepExceptionTests { 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 class TaskletStepExceptionTests { } }); taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -181,6 +185,7 @@ public class TaskletStepExceptionTests { final RuntimeException exception = new RuntimeException(); taskletStep.setStepExecutionListeners(new StepExecutionListenerSupport[] { new StepExecutionListenerSupport() { + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { throw exception; @@ -230,6 +235,7 @@ public class TaskletStepExceptionTests { 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 @@ public class TaskletStepExceptionTests { 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 class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -311,6 +319,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -332,6 +341,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -355,6 +365,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -375,6 +386,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -396,6 +408,7 @@ public class TaskletStepExceptionTests { taskletStep.setTasklet(new Tasklet() { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext attributes) throws Exception { return RepeatStatus.FINISHED; @@ -419,6 +432,7 @@ public class TaskletStepExceptionTests { 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 class TaskletStepExceptionTests { private static class ExceptionTasklet implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { throw taskletException; @@ -505,6 +520,7 @@ public class TaskletStepExceptionTests { return null; } + @Nullable @Override public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) { return null; @@ -548,6 +564,7 @@ public class TaskletStepExceptionTests { 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 400af1668..074ac5a1e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.core.launch.JobLauncher; 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 class ReprocessExceptionTests { 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 913c14a5c..a422a7199 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import org.springframework.batch.repeat.support.RepeatTemplate; 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 class AsyncTaskletStepTests { 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 84c65c4d9..8f1908c2e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,6 +45,7 @@ import org.springframework.batch.item.ItemWriter; 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 class StepExecutorInterruptionTests { // 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 class StepExecutorInterruptionTests { Thread processingThread = createThread(stepExecution); step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader() { + @Nullable @Override public Object read() throws Exception { return null; @@ -200,6 +203,7 @@ public class StepExecutorInterruptionTests { }); 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 b656c34b2..8fca070f5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,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.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 class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -271,6 +273,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -297,6 +300,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -307,6 +311,7 @@ public class TaskletStepTests { 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 class TaskletStepTests { @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 class TaskletStepTests { @Test public void testStreamManager() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Nullable @Override public String read() { return "foo"; @@ -480,6 +487,7 @@ public class TaskletStepTests { list.add("foo"); } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { list.add("bar"); @@ -519,6 +527,7 @@ public class TaskletStepTests { 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 class TaskletStepTests { @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 class TaskletStepTests { } }); step.setTasklet(new TestingChunkOrientedTasklet<>(new MockRestartableItemReader() { + @Nullable @Override public String read() throws RuntimeException { throw new RuntimeException("FOO"); @@ -564,6 +575,7 @@ public class TaskletStepTests { @Test public void testDirectlyInjectedStreamWhichIsAlsoReader() throws Exception { MockRestartableItemReader reader = new MockRestartableItemReader() { + @Nullable @Override public String read() { return "foo"; @@ -604,6 +616,7 @@ public class TaskletStepTests { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { throw new RuntimeException(); @@ -630,6 +643,7 @@ public class TaskletStepTests { public void testStatusForNormalFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -654,6 +668,7 @@ public class TaskletStepTests { public void testStatusForErrorFailure() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -679,6 +694,7 @@ public class TaskletStepTests { public void testStatusForResetFailedException() throws Exception { ItemReader itemReader = new ItemReader() { + @Nullable @Override public String read() throws Exception { // Trigger a rollback @@ -801,6 +817,7 @@ public class TaskletStepTests { @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 class TaskletStepTests { @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 class TaskletStepTests { 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 class TaskletStepTests { @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 @@ public class TaskletStepTests { private boolean restoreFromCalled = false; + @Nullable @Override public String read() { return "item"; @@ -951,6 +972,7 @@ public class TaskletStepTests { return restoreFromCalled; } + @Nullable @Override public ExitStatus afterStep(StepExecution stepExecution) { return null; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java index 9ef302c89..6a608e337 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,11 @@ package org.springframework.batch.core.step.tasklet; 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 TaskletSupport implements Tasklet { + @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java index 1fed949a6..dc01e623e 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.batch.repeat.support.RepeatTemplate; 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; @@ -81,6 +82,7 @@ public class ExternalRetryInBatchTests { jmsTemplate.convertAndSend("queue", "foo"); jmsTemplate.convertAndSend("queue", "bar"); provider = new ItemReader() { + @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 eaa2faf25..df41e25ec 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.batch.item.ItemWriter; 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 class ExternalRetryTests { 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 5572d7205..d5185bd16 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 b4a530240..a198c8ee0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.item.amqp; 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 class AmqpItemReader implements ItemReader { 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 e34dc8307..3725ad5e6 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.ItemReader; 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 class AvroItemReader extends AbstractItemCountingItemStreamItemReader< } + @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 2454bdae8..2c1604ce1 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.item.data; 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 @@ AbstractItemCountingItemStreamItemReader { 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 e0b319d7b..ae3b6b2d4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.data.domain.PageRequest; 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 class RepositoryItemReader extends AbstractItemCountingItemStreamItemR 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 51725be4b..d37040cc9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -465,6 +465,7 @@ implements InitializingBean { * 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 ac161133b..57a975e39 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; 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 abstract class AbstractPagingItemReader extends AbstractItemCountingIt 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 1ece059b5..5769e267f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2017 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.item.ItemStreamException; 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 class HibernateCursorItemReader extends AbstractItemCountingItemStream 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 ba69ae46c..94a7d4c1e 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 java.sql.SQLException; 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 @@ public class JdbcCursorItemReader extends AbstractCursorItemReader { } + @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 bff3dc3b9..27210a055 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.jdbc.core.SqlOutParameter; 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 @@ public class StoredProcedureItemReader extends AbstractCursorItemReader { } + @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 b5ab389ce..c5eeddef4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy 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 class FlatFileItemReader extends AbstractItemCountingItemStreamItemRea * @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 @@ public class FlatFileItemReader extends AbstractItemCountingItemStreamItemRea /** * @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 25a10b691..df3d0ead4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,6 +92,7 @@ public class MultiResourceItemReader extends AbstractItemStreamItemReader /** * 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 88da1b04f..394ef73c8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; /** @@ -120,7 +121,7 @@ public abstract class AbstractLineTokenizer implements LineTokenizer { * @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 e3549e91a..35075f904 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.Map; 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 e5ecadec4..7de337a05 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 @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.item.function; 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 class FunctionItemProcessor implements ItemProcessor{ 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 0d7ee6654..9414b4e72 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.item.ItemReader; 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 class JmsItemReader implements ItemReader, InitializingBean { 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 159f66d3a..44f2c4e0b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.google.gson.stream.JsonToken; 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 class GsonJsonObjectReader implements JsonObjectReader { 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 db1c228cf..18e853e8d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; 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 class JacksonJsonObjectReader implements JsonObjectReader { "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 89525c398..1ef19dc68 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 @@ -1,5 +1,5 @@ /* - * Copyright 2018 the original author or authors. + * Copyright 2018-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.batch.item.ItemStreamReader; 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 class JsonItemReader extends AbstractItemCountingItemStreamItemReader< 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 a2cc6aca5..a022b27ea 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.apache.kafka.common.TopicPartition; 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 class KafkaItemReader extends AbstractItemStreamItemReader { 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 3b17116d8..6572dd9fa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2005-2014 the original author or authors. + * Copyright 2005-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.batch.item.file.ResourceAwareItemReaderItemStream; 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 @@ public class LdifReader extends AbstractItemCountingItemStreamItemReader extends AbstractItemCountingItemStreamItemRead } } + @Nullable @Override protected T doRead() throws Exception { LdapAttributes attributes = null; @@ -169,4 +171,4 @@ public class MappingLdifReader extends AbstractItemCountingItemStreamItemRead Assert.notNull(ldifParser, "A parser is required"); } -} \ No newline at end of file +} 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 3ba49fdfa..3c2d6963a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,6 +83,7 @@ public abstract class AbstractItemCountingItemStreamItemReader extends Abstra } } + @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 338d09c5e..482798485 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.item.support; 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 class ClassifierCompositeItemProcessor implements ItemProcessor 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 2919b8ab0..54d1536e3 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 @@ package org.springframework.batch.item.support; 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 class IteratorItemReader implements ItemReader { * 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 ae364f4f1..2def56dc6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.List; 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 class ListItemReader implements ItemReader { } } - @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 5621e1b21..9c9352611 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 18f74f94e..17f3b54a3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 ff6bd6cec..2b29de94e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.item.ItemStreamReader; 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 class SingleItemPeekableItemReader implements ItemStreamReader, Pee * * @see ItemReader#read() */ - @Override + @Nullable + @Override public T read() throws Exception, UnexpectedInputException, ParseException { if (next != null) { T item = next; @@ -86,7 +88,8 @@ public class SingleItemPeekableItemReader implements ItemStreamReader, Pee * * @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 45cc5dd9a..50d200dd5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.item.NonTransientResourceException; 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 class SynchronizedItemStreamReader implements ItemStreamReader, Ini /** * 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 dfc081aaf..156d362e0 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.batch.item.validator; 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 class ValidatingItemProcessor implements ItemProcessor, Initiali * @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 9c5aaf415..ee7598cfc 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.DefaultFragmentEventReader; 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 @@ ResourceAwareItemReaderItemStream, InitializingBean { /** * 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 a8fd13f8a..cc4070aaa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.batch.jsr.item; 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 class ItemProcessorAdapter implements org.springframework.batch.ite 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 df59e91cd..5825205e4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.io.Serializable; 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 class ItemReaderAdapter extends CheckpointSupport implements org.sprin /* (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 0d5670412..33f420114 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference; 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 class AnnotationMethodResolver implements MethodResolver { * @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 class AnnotationMethodResolver implements MethodResolver { * @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 615deabf6..fe16883a8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.lang.reflect.Method; 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 class SimpleMethodInvoker implements MethodInvoker { * 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 001d194ee..670ea0b93 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,14 @@ package org.springframework.batch.item; 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 285a2d4c8..7fa57665d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import org.springframework.core.io.AbstractResource; 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 @@ public class MultiResourceItemReaderIntegrationTests { 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 7a65d2922..1cffddc2f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.item.file.transform.DelimitedLineTokenizer; 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 class PatternMatchingCompositeLineMapperTests { 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 class PatternMatchingCompositeLineMapperTests { 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 2ddc1363f..76cde5cf8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.LinkedHashMap; import java.util.Map; import org.junit.Test; +import org.springframework.lang.Nullable; /** * @author Ben Hale @@ -46,7 +47,7 @@ public class PatternMatchingCompositeLineTokenizerTests { 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 class PatternMatchingCompositeLineTokenizerTests { 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 class PatternMatchingCompositeLineTokenizerTests { 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 eecba6e5c..e47e0eb76 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.junit.Test; 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 class ClassifierCompositeItemProcessorTests { 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 class ClassifierCompositeItemProcessorTests { 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 0bc63dd05..82cfd9d17 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Iterator; 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 @@ public class ItemCountingItemStreamItemReaderTests { 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 98619d66d..8301d0fb8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.List; import org.junit.Test; import org.springframework.batch.item.ExecutionContext; +import org.springframework.lang.Nullable; /** * @author Dave Syer @@ -122,6 +123,7 @@ public class SingleItemPeekableItemReaderTests { 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 ad5212435..73107e472 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 @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.item.ExecutionContext; 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 @@ public class SynchronizedItemStreamReaderTests { 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 ec4573b2c..5facf3993 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 @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.item.NonTransientResourceException; 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 @@ public class SynchronizedItemStreamReaderBuilderTests { 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 8b32d69bc..234d4d0b6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.repeat.RepeatStatus; 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 @@ public class ChunkedRepeatTests extends AbstractTradeBatchTests { 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 dc2d1c990..cd742a6cb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.item.ItemWriter; 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 class AsyncItemProcessor implements ItemProcessor>, In * * @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 a20f95d58..93922fda4 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.batch.item.ItemStream; 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 class ChunkMessageChannelItemWriter extends StepExecutionListenerSuppo 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 6d811a001..46681d00b 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.BeansException; 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 class BeanFactoryStepLocator implements StepLocator, BeanFactoryAware { * 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 dedffa195..79f23a92d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2013 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.core.repository.JobExecutionAlreadyRunningExcep 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 class JobRepositorySupport implements JobRepository { /* (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 class JobRepositorySupport implements JobRepository { /* (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 40b637289..c480dd562 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.JobExecution; 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 class JobSupport implements Job { 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 e06ae00fd..2e26966a7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,12 +30,14 @@ import org.springframework.batch.item.ItemProcessor; 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 class AsyncItemProcessorTests { @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 0efbc4719..0304cbe26 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.context.annotation.Configuration; 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 class RemoteChunkingManagerStepBuilderTest { 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 132ff0841..e3c0be7e6 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.apache.commons.logging.LogFactory; 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 class TestItemReader implements ItemReader { 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 282078bec..8f59844dc 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.ApplicationContext; 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 class RemoteChunkingParserTests { } 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 c9b1c299d..3509c78c8 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.ExecutionContext; 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 8fd02affa..e47a33619 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import org.springframework.batch.core.StepContribution; 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 class TestTasklet implements Tasklet { 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 545fca9df..3b03efb2a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 @@ import org.springframework.batch.item.ItemReader; */ 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 ab81d6540..ffd3d323f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2009-2014 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.springframework.beans.factory.InitializingBean; 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 class StagingItemProcessor implements ItemProcessor 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 7a9cd068a..140d5964c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.beans.factory.InitializingBean; 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 @@ InitializingBean, DisposableBean { } + @Nullable @Override public ProcessIndicatorItemWrapper read() { if (!initialized) { @@ -126,6 +128,7 @@ InitializingBean, DisposableBean { 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 f31889599..74957c029 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.batch.item.ItemWriter; 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 class StagingItemWriter extends JdbcDaoSupport implements StepExecutio * 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 6c9c9cf9f..347c40059 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2010 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.util.Date; 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 fe8bbff27..a81d6ce24 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.List; 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 552db3f74..3a4c110bc 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.springframework.batch.sample.domain.order.Customer; 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 d67ed3d6a..d124d7f44 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.springframework.batch.core.StepExecution; 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 aa80eed3f..7ffe0df4e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.sample.domain.trade; 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 1e368f1a7..aa738b2f7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.math.BigDecimal; 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 565927842..a5269f0d1 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.batch.sample.domain.trade.internal; 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 class TradeProcessor implements ItemProcessor { 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 2105c06ce..79d17cf8e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.core.StepContribution; 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 8e4e68dbe..cd8d827b2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import org.springframework.batch.core.StepExecution; 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 2c71a4347..d98e68d33 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import org.springframework.batch.core.JobExecution; 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 544bc11de..9b1fd9e85 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 @@ import java.util.Date; */ 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 3e26acac6..c0e4ae135 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.batch.sample.support; 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 class ExceptionThrowingItemReaderProxy implements ItemReader { 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 54c559b1e..3ab0ada6a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.springframework.batch.item.ExecutionContext; 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 class CustomItemReaderTests { 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 eb1d00e7c..14baba97e 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.springframework.batch.core.step.tasklet.Tasklet; 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 class ErrorLogTasklet implements Tasklet, StepExecutionListener { 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 5ffc10018..01f738dd2 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,12 @@ import org.springframework.batch.core.JobExecution; 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 class SkipCheckingDecider implements JobExecutionDecider { 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 a9d9a5405..1b427a17d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.Collection; 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 class AggregateItemReaderTests { 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 38935c1ff..49f2da26a 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import org.junit.Test; 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 class CompositeCustomerUpdateLineTokenizerTests { } @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 48569970c..b040bdf56 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.batch.item.ItemStreamException; 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 4f00a6887..d74db4aec 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2014 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import org.springframework.batch.core.launch.JobLauncher; 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 class JobLauncherDetailsTests { 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 class JobLauncherDetailsTests { 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 30b9e0074..3920f1ce8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.context.ApplicationContext; 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 class JobLauncherTestUtilsTests { @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 69101be96..a915f9147 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 @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007 the original author or authors. + * Copyright 2006-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import org.springframework.batch.core.JobParametersIncrementer; 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 class JobRepositoryTestUtilsTests { 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 89f64b68b..f84aeeebd 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 @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import org.springframework.context.annotation.Bean; 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 class StepScopeAnnotatedListenerIntegrationTests { return stepExecution.getExitStatus(); } + @Nullable @Override public String read() throws Exception { this.list.add("some stateful reading information"); @@ -136,6 +138,7 @@ public class StepScopeAnnotatedListenerIntegrationTests { 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 a86a82e38..803bc3f15 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.batch.core.StepContribution; 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 class LoggingTasklet implements Tasklet { 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 743c7b254..f27dada35 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 @@ -1,5 +1,5 @@ /* - * Copyright 2008-2012 the original author or authors. + * Copyright 2008-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import org.springframework.batch.item.ExecutionContext; 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 class SampleTasklet implements Tasklet { 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);