35
35
*/
36
36
public class DefaultRetryHandler implements RetryHandler {
37
37
38
- private final BiPredicate <RecordedQueue , Exception > queueRecoveryRetryCondition ;
39
- private final BiPredicate <RecordedExchange , Exception > exchangeRecoveryRetryCondition ;
40
- private final BiPredicate <RecordedBinding , Exception > bindingRecoveryRetryCondition ;
41
- private final BiPredicate <RecordedConsumer , Exception > consumerRecoveryRetryCondition ;
38
+ private final BiPredicate <? super RecordedQueue , Exception > queueRecoveryRetryCondition ;
39
+ private final BiPredicate <? super RecordedExchange , Exception > exchangeRecoveryRetryCondition ;
40
+ private final BiPredicate <? super RecordedBinding , Exception > bindingRecoveryRetryCondition ;
41
+ private final BiPredicate <? super RecordedConsumer , Exception > consumerRecoveryRetryCondition ;
42
42
43
43
private final RetryOperation <?> queueRecoveryRetryOperation ;
44
44
private final RetryOperation <?> exchangeRecoveryRetryOperation ;
@@ -49,10 +49,10 @@ public class DefaultRetryHandler implements RetryHandler {
49
49
50
50
private final BackoffPolicy backoffPolicy ;
51
51
52
- public DefaultRetryHandler (BiPredicate <RecordedQueue , Exception > queueRecoveryRetryCondition ,
53
- BiPredicate <RecordedExchange , Exception > exchangeRecoveryRetryCondition ,
54
- BiPredicate <RecordedBinding , Exception > bindingRecoveryRetryCondition ,
55
- BiPredicate <RecordedConsumer , Exception > consumerRecoveryRetryCondition ,
52
+ public DefaultRetryHandler (BiPredicate <? super RecordedQueue , Exception > queueRecoveryRetryCondition ,
53
+ BiPredicate <? super RecordedExchange , Exception > exchangeRecoveryRetryCondition ,
54
+ BiPredicate <? super RecordedBinding , Exception > bindingRecoveryRetryCondition ,
55
+ BiPredicate <? super RecordedConsumer , Exception > consumerRecoveryRetryCondition ,
56
56
RetryOperation <?> queueRecoveryRetryOperation ,
57
57
RetryOperation <?> exchangeRecoveryRetryOperation ,
58
58
RetryOperation <?> bindingRecoveryRetryOperation ,
@@ -72,27 +72,31 @@ public DefaultRetryHandler(BiPredicate<RecordedQueue, Exception> queueRecoveryRe
72
72
this .retryAttempts = retryAttempts ;
73
73
}
74
74
75
+ @ SuppressWarnings ("unchecked" )
75
76
@ Override
76
77
public RetryResult retryQueueRecovery (RetryContext context ) throws Exception {
77
- return doRetry (queueRecoveryRetryCondition , queueRecoveryRetryOperation , context .queue (), context );
78
+ return doRetry (( BiPredicate < RecordedEntity , Exception >) queueRecoveryRetryCondition , queueRecoveryRetryOperation , context .queue (), context );
78
79
}
79
80
81
+ @ SuppressWarnings ("unchecked" )
80
82
@ Override
81
83
public RetryResult retryExchangeRecovery (RetryContext context ) throws Exception {
82
- return doRetry (exchangeRecoveryRetryCondition , exchangeRecoveryRetryOperation , context .exchange (), context );
84
+ return doRetry (( BiPredicate < RecordedEntity , Exception >) exchangeRecoveryRetryCondition , exchangeRecoveryRetryOperation , context .exchange (), context );
83
85
}
84
86
87
+ @ SuppressWarnings ("unchecked" )
85
88
@ Override
86
89
public RetryResult retryBindingRecovery (RetryContext context ) throws Exception {
87
- return doRetry (bindingRecoveryRetryCondition , bindingRecoveryRetryOperation , context .binding (), context );
90
+ return doRetry (( BiPredicate < RecordedEntity , Exception >) bindingRecoveryRetryCondition , bindingRecoveryRetryOperation , context .binding (), context );
88
91
}
89
92
93
+ @ SuppressWarnings ("unchecked" )
90
94
@ Override
91
95
public RetryResult retryConsumerRecovery (RetryContext context ) throws Exception {
92
- return doRetry (consumerRecoveryRetryCondition , consumerRecoveryRetryOperation , context .consumer (), context );
96
+ return doRetry (( BiPredicate < RecordedEntity , Exception >) consumerRecoveryRetryCondition , consumerRecoveryRetryOperation , context .consumer (), context );
93
97
}
94
98
95
- protected < T extends RecordedEntity > RetryResult doRetry (BiPredicate <T , Exception > condition , RetryOperation <?> operation , T entity , RetryContext context )
99
+ protected RetryResult doRetry (BiPredicate <RecordedEntity , Exception > condition , RetryOperation <?> operation , RecordedEntity entity , RetryContext context )
96
100
throws Exception {
97
101
int attempts = 0 ;
98
102
Exception exception = context .exception ();
@@ -107,7 +111,6 @@ protected <T extends RecordedEntity> RetryResult doRetry(BiPredicate<T, Exceptio
107
111
} catch (Exception e ) {
108
112
exception = e ;
109
113
attempts ++;
110
- continue ;
111
114
}
112
115
} else {
113
116
throw exception ;
0 commit comments