BATCH-1284: fixed by using upgradeStatus in AbstractStep

This commit is contained in:
dsyer
2009-06-10 07:35:55 +00:00
parent 56e304ebcf
commit 8cabd9544f
2 changed files with 26 additions and 1 deletions

View File

@@ -207,7 +207,8 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
throw new JobInterruptedException("JobExecution interrupted.");
}
stepExecution.setStatus(BatchStatus.COMPLETED);
// Need to upgrade here not set, in case the execution was stopped
stepExecution.upgradeStatus(BatchStatus.COMPLETED);
logger.debug("Step execution success: id=" + stepExecution.getId());
}
catch (Throwable e) {

View File

@@ -104,4 +104,28 @@ public class PartitionStepTests {
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
}
@Test
public void testStoppedStepExecution() throws Exception {
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, remote));
step.setPartitionHandler(new PartitionHandler() {
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
throws Exception {
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
for (StepExecution execution : executions) {
execution.setStatus(BatchStatus.STOPPED);
execution.setExitStatus(ExitStatus.STOPPED);
}
return executions;
}
});
step.afterPropertiesSet();
JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters());
StepExecution stepExecution = jobExecution.createStepExecution("foo");
jobRepository.add(stepExecution);
step.execute(stepExecution);
// one master and two workers
assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size());
assertEquals(BatchStatus.STOPPED, stepExecution.getStatus());
}
}