Added @Nullable annotation to overriding methods.
Resolves BATCH-2839
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
4ec227cd6e
commit
a7092a21e4
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<Object,Object> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object process(Object item) throws Exception {
|
||||
return item;
|
||||
|
||||
@@ -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<Object> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object read() throws Exception, UnexpectedInputException, ParseException {
|
||||
return null;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<String, String>{
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
executed = true;
|
||||
|
||||
@@ -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<String> {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String> {
|
||||
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<String, String> {
|
||||
private static int count = 0;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
count++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<JobExecution> findRunningJobExecutions(String jobName) {
|
||||
public Set<JobExecution> 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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<Integer, String>() {
|
||||
@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<Integer, String>() {
|
||||
@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++;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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<String> {
|
||||
/**
|
||||
* Reads next record from input
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
if (index >= input.length || index >= max) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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<String>() {
|
||||
@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<String>() {
|
||||
@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<String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception, UnexpectedInputException, ParseException {
|
||||
return "" + (count++);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@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<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
processedItems.add(item);
|
||||
|
||||
@@ -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<String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception, UnexpectedInputException, ParseException {
|
||||
throw new RuntimeException("Planned");
|
||||
|
||||
@@ -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<String, Integer> processor = new ItemProcessor<String, Integer>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Integer process(String item) throws Exception {
|
||||
processed.add(item);
|
||||
@@ -205,6 +207,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
};
|
||||
|
||||
ItemProcessor<String, String> processor = new ItemProcessor<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
processed.add(item);
|
||||
@@ -253,6 +256,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
};
|
||||
|
||||
ItemProcessor<String, String> processor = new ItemProcessor<String, String>() {
|
||||
@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<String> provider = new ListItemReader<String>(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<String> provider = new ListItemReader<String>(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<String> provider = new ListItemReader<String>(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<String> provider = new ListItemReader<String>(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<String> provider = new ListItemReader<String>(
|
||||
Arrays.asList("b")) {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() {
|
||||
String item = super.read();
|
||||
@@ -612,6 +622,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
factory.setSkipLimit(1);
|
||||
ItemReader<String> provider = new ListItemReader<String>(
|
||||
Arrays.asList("b")) {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() {
|
||||
String item = super.read();
|
||||
@@ -665,6 +676,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
factory.setSkipLimit(0);
|
||||
ItemReader<String> provider = new ListItemReader<String>(
|
||||
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<String> provider = new ItemReader<String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() {
|
||||
String item = "" + count;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<String, String> processor = new SimpleChunkProcessor<>(
|
||||
new ItemProcessor<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
if (item.equals("err")) {
|
||||
|
||||
@@ -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<? extends String> 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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T> extends AbstractExceptionThrowingItemHandlerSt
|
||||
filter = false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public T process(T item) throws Exception {
|
||||
processed.add(item);
|
||||
|
||||
@@ -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<T> extends AbstractExceptionThrowingItemHandlerStub<
|
||||
read.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public T read() throws Exception, UnexpectedInputException, ParseException {
|
||||
counter++;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
logger.info("Item: "+item);
|
||||
|
||||
@@ -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<Object>() {
|
||||
@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<Object>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object read() throws Exception {
|
||||
return null;
|
||||
@@ -200,6 +203,7 @@ public class StepExecutorInterruptionTests {
|
||||
});
|
||||
|
||||
step.setTasklet(new TestingChunkOrientedTasklet<>(new ItemReader<Object>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object read() throws Exception {
|
||||
throw new RuntimeException("Planned!");
|
||||
|
||||
@@ -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<String> itemReader = new ItemReader<String>() {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
throw new RuntimeException();
|
||||
@@ -271,6 +273,7 @@ public class TaskletStepTests {
|
||||
|
||||
ItemReader<String> itemReader = new ItemReader<String>() {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
throw new RuntimeException();
|
||||
@@ -297,6 +300,7 @@ public class TaskletStepTests {
|
||||
|
||||
ItemReader<String> itemReader = new ItemReader<String>() {
|
||||
|
||||
@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<String>() {
|
||||
@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<String> itemReader = new ItemReader<String>() {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
throw new RuntimeException();
|
||||
@@ -630,6 +643,7 @@ public class TaskletStepTests {
|
||||
public void testStatusForNormalFailure() throws Exception {
|
||||
|
||||
ItemReader<String> itemReader = new ItemReader<String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
// Trigger a rollback
|
||||
@@ -654,6 +668,7 @@ public class TaskletStepTests {
|
||||
public void testStatusForErrorFailure() throws Exception {
|
||||
|
||||
ItemReader<String> itemReader = new ItemReader<String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
// Trigger a rollback
|
||||
@@ -679,6 +694,7 @@ public class TaskletStepTests {
|
||||
public void testStatusForResetFailedException() throws Exception {
|
||||
|
||||
ItemReader<String> itemReader = new ItemReader<String>() {
|
||||
@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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user