RESOLVED - BATCH-994: BackOffPolicy is not applied for exceptions that cause rollback

backOff before deciding whether to rethrow
This commit is contained in:
robokaso
2009-01-13 16:27:42 +00:00
parent 811c917edf
commit d574877255
2 changed files with 59 additions and 13 deletions

View File

@@ -236,7 +236,18 @@ public class RetryTemplate implements RetryOperations {
doOnErrorInterceptors(retryCallback, context, e);
registerThrowable(retryPolicy, state, context, e);
try {
backOffPolicy.backOff(backOffContext);
}
catch (BackOffInterruptedException ex) {
lastException = e;
// back off was prevented by another thread - fail the
// retry
logger.debug("Abort retry because interrupted: count=" + context.getRetryCount());
throw ex;
}
if (shouldRethrow(retryPolicy, context, state)) {
logger.debug("Rethrow in retry for policy: count=" + context.getRetryCount());
throw e;
@@ -244,17 +255,6 @@ public class RetryTemplate implements RetryOperations {
}
try {
backOffPolicy.backOff(backOffContext);
}
catch (BackOffInterruptedException e) {
lastException = e;
// back off was prevented by another thread - fail the
// retry
logger.debug("Abort retry because interrupted: count=" + context.getRetryCount());
throw e;
}
/*
* A stateful attempt that can retry should have rethrown the
* exception by now - i.e. we shouldn't get this far for a