IN PROGRESS - BATCH-1010: StepFactoryBeans cleanup
don't treat retryable exceptions automatically as skippable (did it ever make sense?) cleanup misleading and redundant test configurations
This commit is contained in:
@@ -75,9 +75,7 @@ public class FaultTolerantStepFactoryBean<T, S> extends SimpleStepFactoryBean<T,
|
||||
{
|
||||
fatalExceptionClasses.add(Error.class);
|
||||
skippableExceptionClasses.add(Exception.class);
|
||||
// TODO seems to cause trouble, although it shouldn't matter for
|
||||
// retryLimit=0?
|
||||
// retryableExceptionClasses.add(Exception.class);
|
||||
retryableExceptionClasses.add(Exception.class);
|
||||
}
|
||||
|
||||
private int cacheCapacity = 0;
|
||||
@@ -225,8 +223,8 @@ public class FaultTolerantStepFactoryBean<T, S> extends SimpleStepFactoryBean<T,
|
||||
fatalExceptionClasses);
|
||||
|
||||
// TODO why are retryable exceptions automatically skippable?
|
||||
SkipPolicy writeSkipPolicy = new LimitCheckingItemSkipPolicy(skipLimit, union(skippableExceptionClasses,
|
||||
retryableExceptionClasses), fatalExceptionClasses);
|
||||
SkipPolicy writeSkipPolicy = new LimitCheckingItemSkipPolicy(skipLimit, skippableExceptionClasses,
|
||||
fatalExceptionClasses);
|
||||
|
||||
Classifier<Throwable, Boolean> rollbackClassifier = new Classifier<Throwable, Boolean>() {
|
||||
public Boolean classify(Throwable classifiable) {
|
||||
@@ -381,13 +379,4 @@ public class FaultTolerantStepFactoryBean<T, S> extends SimpleStepFactoryBean<T,
|
||||
fatalExceptionClasses = fatalExceptionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return union of the two collections provided as arguments.
|
||||
*/
|
||||
private static <T> Collection<T> union(Collection<T> c1, Collection<T> c2) {
|
||||
Collection<T> result = new ArrayList<T>(c1);
|
||||
result.addAll(c2);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.batch.retry.RetryException;
|
||||
import org.springframework.batch.retry.policy.MapRetryContextCache;
|
||||
import org.springframework.batch.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
@@ -170,11 +169,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
|
||||
@Test
|
||||
public void testSkipAndRetry() throws Exception {
|
||||
factory.setSkippableExceptionClasses(new HashSet<Class<? extends Throwable>>() {
|
||||
{
|
||||
add(Exception.class);
|
||||
}
|
||||
});
|
||||
|
||||
factory.setSkipLimit(2);
|
||||
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("a", "b", "c", "d", "e", "f")) {
|
||||
public String read() {
|
||||
@@ -203,11 +198,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
@Test
|
||||
public void testSkipAndRetryWithWriteFailure() throws Exception {
|
||||
|
||||
factory.setSkippableExceptionClasses(new HashSet<Class<? extends Throwable>>() {
|
||||
{
|
||||
add(RetryException.class);
|
||||
}
|
||||
});
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String,String>() {
|
||||
public void onSkipInWrite(String item, Throwable t) {
|
||||
recovered.add(item);
|
||||
@@ -268,11 +258,6 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
public void testSkipAndRetryWithWriteFailureAndNonTrivialCommitInterval() throws Exception {
|
||||
|
||||
factory.setCommitInterval(3);
|
||||
factory.setSkippableExceptionClasses(new HashSet<Class<? extends Throwable>>() {
|
||||
{
|
||||
add(RetryException.class);
|
||||
}
|
||||
});
|
||||
factory.setListeners(new StepListener[] { new SkipListenerSupport<String,String>() {
|
||||
public void onSkipInWrite(String item, Throwable t) {
|
||||
recovered.add(item);
|
||||
@@ -332,11 +317,7 @@ public class FaultTolerantStepFactoryBeanRetryTests {
|
||||
|
||||
@Test
|
||||
public void testRetryWithNoSkip() throws Exception {
|
||||
factory.setRetryableExceptionClasses(new HashSet<Class<? extends Throwable>>() {
|
||||
{
|
||||
add(Exception.class);
|
||||
}
|
||||
});
|
||||
|
||||
factory.setRetryLimit(4);
|
||||
factory.setSkipLimit(0);
|
||||
ItemReader<String> provider = new ListItemReader<String>(Arrays.asList("b")) {
|
||||
|
||||
Reference in New Issue
Block a user