RESOLVED - BATCH-994: BackOffPolicy is not applied for exceptions that cause rollback
backOff before deciding whether to rethrow
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user