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:
@@ -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) {
|
||||
|
||||
@@ -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(), "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user