@ -133,8 +133,8 @@ public class RetryTemplate implements RetryOperations {
@@ -133,8 +133,8 @@ public class RetryTemplate implements RetryOperations {
Deque < Throwable > exceptions = new ArrayDeque < > ( ) ;
exceptions . add ( initialException ) ;
Throwable retry Exception = initialException ;
while ( this . retryPolicy . shouldRetry ( retry Exception) ) {
Throwable last Exception = initialException ;
while ( this . retryPolicy . shouldRetry ( last Exception) ) {
try {
long duration = backOffExecution . nextBackOff ( ) ;
if ( duration = = BackOffExecution . STOP ) {
@ -159,23 +159,23 @@ public class RetryTemplate implements RetryOperations {
@@ -159,23 +159,23 @@ public class RetryTemplate implements RetryOperations {
. formatted ( retryableName ) ) ;
return result ;
}
catch ( Throwable currentAttempt Exception ) {
catch ( Throwable currentException ) {
logger . debug ( ( ) - > "Retry attempt for operation '%s' failed due to '%s'"
. formatted ( retryableName , currentAttempt Exception ) ) ;
this . retryListener . onRetryFailure ( this . retryPolicy , retryable , currentAttempt Exception ) ;
exceptions . add ( currentAttempt Exception ) ;
retry Exception = currentAttemp tException ;
. formatted ( retryableName , currentException ) ) ;
this . retryListener . onRetryFailure ( this . retryPolicy , retryable , currentException ) ;
exceptions . add ( currentException ) ;
last Exception = currentException ;
}
}
// The RetryPolicy has exhausted at this point, so we throw a RetryException with the
// initial exception as the cause and remaining exceptions as suppressed exceptions.
RetryException final Exception = new RetryException (
// last exception as the cause and remaining exceptions as suppressed exceptions.
RetryException retry Exception = new RetryException (
"Retry policy for operation '%s' exhausted; aborting execution" . formatted ( retryableName ) ,
exceptions . removeLast ( ) ) ;
exceptions . forEach ( final Exception: : addSuppressed ) ;
this . retryListener . onRetryPolicyExhaustion ( this . retryPolicy , retryable , retry Exception) ;
throw final Exception;
exceptions . forEach ( retry Exception: : addSuppressed ) ;
this . retryListener . onRetryPolicyExhaustion ( this . retryPolicy , retryable , last Exception) ;
throw retry Exception;
}
}