RESOLVED - BATCH-838: TimeoutTerminationPolicy does not terminate when eof is encountered
terminate immediately if exit status is not continuable
This commit is contained in:
@@ -30,13 +30,19 @@ import org.springframework.batch.repeat.context.RepeatContextSupport;
|
||||
public class CompletionPolicySupport implements CompletionPolicy {
|
||||
|
||||
/**
|
||||
* Delegate to {@link #isComplete(RepeatContext)}.
|
||||
* Return <code>true</code> if exit status is not continuable, otherwise
|
||||
* delegate to {@link #isComplete(RepeatContext)}.
|
||||
*
|
||||
* @see org.springframework.batch.repeat.CompletionPolicy#isComplete(org.springframework.batch.repeat.RepeatContext,
|
||||
* ExitStatus)
|
||||
*/
|
||||
public boolean isComplete(RepeatContext context, ExitStatus result) {
|
||||
return isComplete(context);
|
||||
if (result != null && !result.isContinuable()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return isComplete(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.batch.repeat.policy;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
|
||||
public class TimeoutCompletionPolicyTests extends TestCase {
|
||||
@@ -35,6 +36,12 @@ public class TimeoutCompletionPolicyTests extends TestCase {
|
||||
RepeatContext context = policy.start(null);
|
||||
assertFalse(policy.isComplete(context, null));
|
||||
}
|
||||
|
||||
public void testNonContinuableResult() throws Exception {
|
||||
TimeoutTerminationPolicy policy = new TimeoutTerminationPolicy();
|
||||
ExitStatus result = new ExitStatus(false, "non-continuable exit status");
|
||||
assertTrue(policy.isComplete(policy.start(null), result));
|
||||
}
|
||||
|
||||
public void testUpdate() throws Exception {
|
||||
TimeoutTerminationPolicy policy = new TimeoutTerminationPolicy(20L);
|
||||
|
||||
Reference in New Issue
Block a user