RESOLVED - issue BATCH-722: No framework logic should depend on the value of ExitStatus

This commit is contained in:
dsyer
2008-07-13 11:48:41 +00:00
parent cf6a6e34f0
commit 11a84dd267
6 changed files with 55 additions and 25 deletions

View File

@@ -21,14 +21,14 @@ import java.util.Iterator;
import java.util.List;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.StartLimitExceededException;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobInterruptedException;
import org.springframework.batch.core.StartLimitExceededException;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.ExitStatus;
@@ -87,10 +87,10 @@ public class SimpleJob extends AbstractJob {
StepExecution lastStepExecution = getJobRepository().getLastStepExecution(jobInstance, step);
boolean isRestart = (getJobRepository().getStepExecutionCount(jobInstance, step) > 0 && !lastStepExecution
.getExitStatus().equals(ExitStatus.FINISHED)) ? true : false;
boolean isRestart = (lastStepExecution != null && !lastStepExecution.getStatus().equals(
BatchStatus.COMPLETED)) ? true : false;
if (isRestart && lastStepExecution != null) {
if (isRestart) {
currentStepExecution.setExecutionContext(lastStepExecution.getExecutionContext());
}
else {

View File

@@ -346,7 +346,6 @@ public class SimpleJobTests extends TestCase {
assertSame(exception, e);
}
assertTrue(step1.passedInStepContext.isEmpty());
System.err.println(step2.passedInStepContext);
assertFalse(step2.passedInStepContext.isEmpty());
}
@@ -504,20 +503,24 @@ public class SimpleJobTests extends TestCase {
if (exception instanceof RuntimeException) {
stepExecution.setExitStatus(ExitStatus.FAILED);
stepExecution.setStatus(BatchStatus.FAILED);
throw (RuntimeException) exception;
}
if (exception instanceof Error) {
stepExecution.setExitStatus(ExitStatus.FAILED);
stepExecution.setStatus(BatchStatus.FAILED);
throw (Error) exception;
}
if (exception instanceof JobInterruptedException) {
stepExecution.setExitStatus(ExitStatus.FAILED);
stepExecution.setStatus(BatchStatus.FAILED);
throw (JobInterruptedException) exception;
}
if (runnable != null) {
runnable.run();
}
stepExecution.setExitStatus(ExitStatus.FINISHED);
stepExecution.setStatus(BatchStatus.COMPLETED);
}