1
1
/*
2
- * Copyright 2006-2022 the original author or authors.
2
+ * Copyright 2006-2020 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -96,8 +96,6 @@ public class RetryTemplate implements RetryOperations {
96
96
97
97
private boolean throwLastExceptionOnExhausted ;
98
98
99
- private boolean noRecoveryForNotRetryable ;
100
-
101
99
/**
102
100
* Main entry point to configure RetryTemplate using fluent API. See
103
101
* {@link RetryTemplateBuilder} for usage examples and details.
@@ -126,14 +124,6 @@ public void setThrowLastExceptionOnExhausted(boolean throwLastExceptionOnExhaust
126
124
this .throwLastExceptionOnExhausted = throwLastExceptionOnExhausted ;
127
125
}
128
126
129
- /**
130
- * @param noRecoveryForNotRetryable the noRecoveryForNotRetryable to set
131
- * @since 1.3.3
132
- */
133
- public void setNoRecoveryForNotRetryable (boolean noRecoveryForNotRetryable ) {
134
- this .noRecoveryForNotRetryable = noRecoveryForNotRetryable ;
135
- }
136
-
137
127
/**
138
128
* Public setter for the {@link RetryContextCache}.
139
129
* @param retryContextCache the {@link RetryContextCache} to set.
@@ -376,6 +366,7 @@ protected <T, E extends Throwable> T doExecute(RetryCallback<T, E> retryCallback
376
366
}
377
367
throw RetryTemplate .<E >wrapIfNecessary (e );
378
368
}
369
+
379
370
}
380
371
381
372
/*
@@ -393,7 +384,7 @@ protected <T, E extends Throwable> T doExecute(RetryCallback<T, E> retryCallback
393
384
}
394
385
395
386
exhausted = true ;
396
- return handleRetryExhausted (recoveryCallback , context , state , retryPolicy );
387
+ return handleRetryExhausted (recoveryCallback , context , state );
397
388
398
389
}
399
390
catch (Throwable e ) {
@@ -471,6 +462,7 @@ private void registerContext(RetryContext context, RetryState state) {
471
462
* was encountered
472
463
*/
473
464
protected RetryContext open (RetryPolicy retryPolicy , RetryState state ) {
465
+
474
466
if (state == null ) {
475
467
return doOpenInternal (retryPolicy );
476
468
}
@@ -504,6 +496,7 @@ protected RetryContext open(RetryPolicy retryPolicy, RetryState state) {
504
496
context .removeAttribute (RetryContext .EXHAUSTED );
505
497
context .removeAttribute (RetryContext .RECOVERED );
506
498
return context ;
499
+
507
500
}
508
501
509
502
private RetryContext doOpenInternal (RetryPolicy retryPolicy , RetryState state ) {
@@ -536,16 +529,12 @@ private RetryContext doOpenInternal(RetryPolicy retryPolicy) {
536
529
* @return T the payload to return
537
530
* @throws Throwable if there is an error
538
531
*/
539
- protected <T > T handleRetryExhausted (RecoveryCallback <T > recoveryCallback , RetryContext context , RetryState state ,
540
- RetryPolicy retryPolicy ) throws Throwable {
532
+ protected <T > T handleRetryExhausted (RecoveryCallback <T > recoveryCallback , RetryContext context , RetryState state )
533
+ throws Throwable {
541
534
context .setAttribute (RetryContext .EXHAUSTED , true );
542
535
if (state != null && !context .hasAttribute (GLOBAL_STATE )) {
543
536
this .retryContextCache .remove (state .getKey ());
544
537
}
545
- if (this .noRecoveryForNotRetryable && retryPolicy instanceof SimpleRetryPolicy
546
- && !((SimpleRetryPolicy ) retryPolicy ).retryForException (context .getLastThrowable ())) {
547
- throw context .getLastThrowable ();
548
- }
549
538
if (recoveryCallback != null ) {
550
539
T recovered = recoveryCallback .recover (context );
551
540
context .setAttribute (RetryContext .RECOVERED , true );
@@ -559,7 +548,7 @@ protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, Retry
559
548
}
560
549
561
550
protected <E extends Throwable > void rethrow (RetryContext context , String message ) throws E {
562
- if (this .throwLastExceptionOnExhausted || this . noRecoveryForNotRetryable ) {
551
+ if (this .throwLastExceptionOnExhausted ) {
563
552
@ SuppressWarnings ("unchecked" )
564
553
E rethrow = (E ) context .getLastThrowable ();
565
554
throw rethrow ;
@@ -583,13 +572,15 @@ protected boolean shouldRethrow(RetryPolicy retryPolicy, RetryContext context, R
583
572
}
584
573
585
574
private <T , E extends Throwable > boolean doOpenInterceptors (RetryCallback <T , E > callback , RetryContext context ) {
575
+
586
576
boolean result = true ;
587
577
588
578
for (RetryListener listener : this .listeners ) {
589
579
result = result && listener .open (context , callback );
590
580
}
591
581
592
582
return result ;
583
+
593
584
}
594
585
595
586
private <T , E extends Throwable > void doCloseInterceptors (RetryCallback <T , E > callback , RetryContext context ,
0 commit comments