RESOLVED - issue BATCH-973: Switch RetryPolicy back to Throwable instead of Exception as in 1.x

http://jira.springframework.org/browse/BATCH-973
This commit is contained in:
dsyer
2009-09-24 08:24:47 +00:00
parent ab5ece862a
commit 6ef8865ce2
18 changed files with 64 additions and 43 deletions

View File

@@ -123,7 +123,7 @@ public class BatchRetryTemplate implements RetryOperations {
}
@Override
protected void registerThrowable(RetryPolicy retryPolicy, RetryState state, RetryContext context, Exception e) {
protected void registerThrowable(RetryPolicy retryPolicy, RetryState state, RetryContext context, Throwable e) {
BatchRetryState batchState = (BatchRetryState) state;
BatchRetryContext batchContext = (BatchRetryContext) context;

View File

@@ -222,7 +222,7 @@ public class Chunk<W> implements Iterable<W> {
return next;
}
public void remove(Exception e) {
public void remove(Throwable e) {
remove();
skips.add(new SkipWrapper<W>(next, e));
}

View File

@@ -248,7 +248,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
RecoveryCallback<O> recoveryCallback = new RecoveryCallback<O>() {
public O recover(RetryContext context) throws Exception {
Exception e = context.getLastThrowable();
Throwable e = context.getLastThrowable();
if (itemProcessSkipPolicy.shouldSkip(e, contribution.getStepSkipCount())) {
contribution.incrementProcessSkipCount();
iterator.remove(e);
@@ -315,7 +315,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
public Object recover(RetryContext context) throws Exception {
Exception e = context.getLastThrowable();
Throwable e = context.getLastThrowable();
if (outputs.size() > 1 && !rollbackClassifier.classify(e)) {
throw new RetryException("Invalid retry state during write caused by "
+ "exception that does not classify for rollback: ", e);
@@ -387,12 +387,12 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
if (item == null) {
continue;
}
Exception e = wrapper.getException();
Throwable e = wrapper.getException();
callProcessSkipListener(item, e);
}
for (SkipWrapper<O> wrapper : outputs.getSkips()) {
Exception e = wrapper.getException();
Throwable e = wrapper.getException();
try {
getListener().onSkipInWrite(wrapper.getItem(), e);
}
@@ -414,7 +414,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
* @param item the item that is skipped
* @param e the cause of the skip
*/
private void callProcessSkipListener(I item, Exception e) {
private void callProcessSkipListener(I item, Throwable e) {
try {
getListener().onSkipInProcess(item, e);
}
@@ -442,7 +442,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
}
private void checkSkipPolicy(Chunk<I>.ChunkIterator inputIterator, Chunk<O>.ChunkIterator outputIterator,
Exception e, StepContribution contribution) {
Throwable e, StepContribution contribution) {
logger.debug("Checking skip policy after failed write");
if (itemWriteSkipPolicy.shouldSkip(e, contribution.getStepSkipCount())) {
contribution.incrementWriteSkipCount();

View File

@@ -24,7 +24,7 @@ package org.springframework.batch.core.step.item;
*/
public class SkipWrapper<T> {
final private Exception exception;
final private Throwable exception;
final private T item;
@@ -38,12 +38,12 @@ public class SkipWrapper<T> {
/**
* @param e
*/
public SkipWrapper(Exception e) {
public SkipWrapper(Throwable e) {
this(null, e);
}
public SkipWrapper(T item, Exception e) {
public SkipWrapper(T item, Throwable e) {
this.item = item;
this.exception = e;
}
@@ -52,7 +52,7 @@ public class SkipWrapper<T> {
* Public getter for the exception.
* @return the exception
*/
public Exception getException() {
public Throwable getException() {
return exception;
}

View File

@@ -99,10 +99,10 @@ public class FaultTolerantChunkProcessorTests {
}
/**
* An Error pops right back up (no skips, no retry)
* An Error can be retried or skipped but by default it is just propagated
* @throws Exception
*/
@Test(expected=AssertionError.class)
@Test
public void testWriteSkipOnError() throws Exception {
processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
processor.setItemWriter(new ItemWriter<String>() {