OPEN - issue BATCH-423: SimpleExitStatusExceptionClassifier never returns a value that will result in ExitMapper.JVM_EXITCODE_JOB_ERROR

Applied patch from Doug.
This commit is contained in:
dsyer
2008-03-07 08:41:44 +00:00
parent f5e85d5f63
commit dc40160583
2 changed files with 15 additions and 0 deletions

View File

@@ -19,7 +19,9 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.repository.NoSuchJobException;
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
import org.springframework.batch.execution.launch.support.ExitCodeMapper;
import org.springframework.batch.repeat.ExitStatus;
/**
@@ -53,6 +55,8 @@ public class SimpleExitStatusExceptionClassifier implements
if (throwable instanceof JobInterruptedException) {
exitStatus = new ExitStatus(false, JOB_INTERRUPTED,
JobInterruptedException.class.getName());
} else if( throwable instanceof NoSuchJobException ) {
exitStatus = new ExitStatus(false, ExitCodeMapper.NO_SUCH_JOB);
} else {
String message = "";
if (throwable!=null) {

View File

@@ -17,7 +17,9 @@ package org.springframework.batch.execution.step.support;
import org.springframework.batch.core.domain.JobInterruptedException;
import org.springframework.batch.core.repository.NoSuchJobException;
import org.springframework.batch.core.runtime.ExitStatusExceptionClassifier;
import org.springframework.batch.execution.launch.support.ExitCodeMapper;
import org.springframework.batch.execution.step.support.SimpleExitStatusExceptionClassifier;
import org.springframework.batch.repeat.ExitStatus;
@@ -74,4 +76,13 @@ public class SimpleExitStatusExceptionClassifierTests extends TestCase {
assertEquals(exitStatus.getExitDescription(),
JobInterruptedException.class.getName());
}
/**
* a NoSuchJobException should lead to the related constant
*/
public void testClassifyNoSuchJobException() {
ExitStatus exitStatus = (ExitStatus)classifier.classifyForExitCode(new NoSuchJobException(""));
assertEquals(exitStatus.getExitCode(), ExitCodeMapper.NO_SUCH_JOB);
assertEquals(exitStatus.getExitDescription(), "");
}
}