BATCH-1064: Changed BatchStatus.FAILED to BatchStatus.INCOMPLETE where necessary
This commit is contained in:
@@ -241,8 +241,8 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In
|
||||
|
||||
// The job was already stopped before we even got this far. Deal
|
||||
// with it in the same way as any other interruption.
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
execution.setExitStatus(ExitStatus.COMPLETED);
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
execution.setStatus(BatchStatus.INCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In
|
||||
* @return the {@link StepExecution} corresponding to this step
|
||||
*
|
||||
* @throws JobInterruptedException if the {@link JobExecution} has been
|
||||
* interrupted, and in particular if {@link BatchStatus#FAILED} or
|
||||
* interrupted, and in particular if {@link BatchStatus#INCOMPLETE} or
|
||||
* {@link BatchStatus#STOPPING} is detected
|
||||
* @throws StartLimitExceededException if the start limit has been exceeded
|
||||
* for this step
|
||||
@@ -331,8 +331,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In
|
||||
|
||||
jobRepository.updateExecutionContext(execution);
|
||||
|
||||
if (currentStepExecution.getStatus() == BatchStatus.FAILED
|
||||
|| currentStepExecution.getStatus() == BatchStatus.STOPPING) {
|
||||
if (currentStepExecution.getStatus() == BatchStatus.STOPPING) {
|
||||
throw new JobInterruptedException("Job interrupted by step execution");
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
|
||||
// Check if someone is trying to stop us
|
||||
if (stepExecution.isTerminateOnly()) {
|
||||
stepExecution.setStatus(BatchStatus.FAILED);
|
||||
stepExecution.setStatus(BatchStatus.INCOMPLETE);
|
||||
throw new JobInterruptedException("JobExecution interrupted.");
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
return BatchStatus.UNKNOWN;
|
||||
}
|
||||
else if (e instanceof JobInterruptedException || e.getCause() instanceof JobInterruptedException) {
|
||||
return BatchStatus.FAILED;
|
||||
return BatchStatus.INCOMPLETE;
|
||||
}
|
||||
else {
|
||||
return BatchStatus.INCOMPLETE;
|
||||
|
||||
@@ -257,7 +257,7 @@ public class TaskletStep extends AbstractStep {
|
||||
locked = true;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
stepExecution.setStatus(BatchStatus.FAILED);
|
||||
stepExecution.setStatus(BatchStatus.INCOMPLETE);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ public class SimpleJobTests {
|
||||
job.execute(jobExecution);
|
||||
|
||||
assertEquals(0, list.size());
|
||||
checkRepository(BatchStatus.FAILED, ExitStatus.NOOP);
|
||||
checkRepository(BatchStatus.INCOMPLETE, ExitStatus.NOOP);
|
||||
ExitStatus exitStatus = jobExecution.getExitStatus();
|
||||
assertEquals(ExitStatus.NOOP.getExitCode(), exitStatus.getExitCode());
|
||||
}
|
||||
@@ -548,7 +548,7 @@ public class SimpleJobTests {
|
||||
}
|
||||
if (exception instanceof JobInterruptedException) {
|
||||
stepExecution.setExitStatus(ExitStatus.FAILED);
|
||||
stepExecution.setStatus(BatchStatus.FAILED);
|
||||
stepExecution.setStatus(BatchStatus.STOPPING);
|
||||
stepExecution.addFailureException(exception);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class AbstractStepTests {
|
||||
tested.setStepExecutionListeners(new StepExecutionListener[] { listener1, listener2 });
|
||||
|
||||
tested.execute(execution);
|
||||
assertEquals(BatchStatus.FAILED, execution.getStatus());
|
||||
assertEquals(BatchStatus.INCOMPLETE, execution.getStatus());
|
||||
Throwable expected = execution.getFailureExceptions().get(0);
|
||||
assertEquals("JobExecution interrupted.", expected.getMessage());
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TaskletStepExceptionTests {
|
||||
public void testInterrupted() throws Exception {
|
||||
taskletStep.setStepExecutionListeners(new StepExecutionListener[] { new InterruptionListener() });
|
||||
taskletStep.execute(stepExecution);
|
||||
assertEquals(FAILED, stepExecution.getStatus());
|
||||
assertEquals(INCOMPLETE, stepExecution.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -114,7 +114,7 @@ public class StepExecutorInterruptionTests extends TestCase {
|
||||
|
||||
assertTrue("Timed out waiting for step to be interrupted.", count < 1000);
|
||||
assertFalse(processingThread.isAlive());
|
||||
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
|
||||
assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus());
|
||||
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class StepExecutorInterruptionTests extends TestCase {
|
||||
|
||||
assertTrue("Timed out waiting for step to be interrupted.", count < 1000);
|
||||
assertFalse(processingThread.isAlive());
|
||||
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
|
||||
assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +541,7 @@ public class TaskletStepTests {
|
||||
stepExecution.setExecutionContext(foobarEc);
|
||||
|
||||
step.execute(stepExecution);
|
||||
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
|
||||
assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus());
|
||||
String msg = stepExecution.getExitStatus().getExitDescription();
|
||||
assertTrue("Message does not contain 'JobInterruptedException': " + msg, contains(msg,
|
||||
"JobInterruptedException"));
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.springframework.batch.sample;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.batch.core.BatchStatus.STARTED;
|
||||
import static org.springframework.batch.core.BatchStatus.FAILED;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -15,6 +13,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.configuration.ListableJobRegistry;
|
||||
@@ -79,7 +78,7 @@ public class JobOperatorFunctionalTests {
|
||||
Thread.sleep(1000);
|
||||
|
||||
assertTrue(tested.getRunningExecutions(job.getName()).contains(executionId));
|
||||
assertTrue(tested.getSummary(executionId).contains(STARTED.toString()));
|
||||
assertTrue(tested.getSummary(executionId).contains(BatchStatus.STARTED.toString()));
|
||||
|
||||
tested.stop(executionId);
|
||||
|
||||
@@ -91,12 +90,12 @@ public class JobOperatorFunctionalTests {
|
||||
}
|
||||
|
||||
assertFalse(tested.getRunningExecutions(job.getName()).contains(executionId));
|
||||
assertTrue(tested.getSummary(executionId).contains(FAILED.toString()));
|
||||
assertTrue(tested.getSummary(executionId).contains(BatchStatus.INCOMPLETE.toString()));
|
||||
|
||||
// there is just a single step in the test job
|
||||
Map<Long, String> summaries = tested.getStepExecutionSummaries(executionId);
|
||||
assertEquals(1, summaries.size());
|
||||
assertTrue(summaries.values().toString().contains(FAILED.toString()));
|
||||
assertTrue(summaries.values().toString().contains(BatchStatus.INCOMPLETE.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user