@@ -27,7 +27,7 @@ public final class ExceptionHandler implements Serializable {
2727 private final ImmutableList <Interceptor > interceptors ;
2828 private final ImmutableSet <Class <? extends Exception >> retriableExceptions ;
2929 private final ImmutableSet <Class <? extends Exception >> nonRetriableExceptions ;
30- private final Set <RetryInfo > retryInfo = Sets .newHashSet ();
30+ private final Set <RetryInfo > retryInfos = Sets .newHashSet ();
3131
3232 public interface Interceptor extends Serializable {
3333
@@ -38,7 +38,7 @@ enum RetryResult {
3838
3939 private final boolean booleanValue ;
4040
41- RetryResult (boolean booleanValue ) {
41+ private RetryResult (boolean booleanValue ) {
4242 this .booleanValue = booleanValue ;
4343 }
4444
@@ -55,7 +55,7 @@ boolean booleanValue() {
5555 * ({@link RetryResult#RETRY}), propagated ({@link RetryResult#ABORT}),
5656 * or evaluation should proceed ({@code null}).
5757 */
58- RetryResult beforeEval (Exception exception );
58+ RetryResult shouldRetry (Exception exception );
5959
6060 /**
6161 * This method is called after the evaluation and could alter its result.
@@ -66,7 +66,7 @@ boolean booleanValue() {
6666 * ({@link RetryResult#RETRY}), propagated ({@link RetryResult#ABORT}),
6767 * or evaluation should proceed ({@code null}).
6868 */
69- RetryResult afterEval (Exception exception , RetryResult retryResult );
69+ RetryResult shouldRetry (Exception exception , RetryResult retryResult );
7070 }
7171
7272 /**
@@ -173,30 +173,31 @@ private ExceptionHandler(Builder builder) {
173173 Sets .intersection (retriableExceptions , nonRetriableExceptions ).isEmpty (),
174174 "Same exception was found in both retriable and non-retriable sets" );
175175 for (Class <? extends Exception > exception : retriableExceptions ) {
176- addRetryInfo ( new RetryInfo (exception , Interceptor .RetryResult .RETRY ), retryInfo );
176+ addToRetryInfos ( retryInfos , new RetryInfo (exception , Interceptor .RetryResult .RETRY ));
177177 }
178178 for (Class <? extends Exception > exception : nonRetriableExceptions ) {
179- addRetryInfo ( new RetryInfo (exception , Interceptor .RetryResult .ABORT ), retryInfo );
179+ addToRetryInfos ( retryInfos , new RetryInfo (exception , Interceptor .RetryResult .ABORT ));
180180 }
181181 }
182182
183- private static void addRetryInfo ( RetryInfo retryInfo , Set < RetryInfo > dest ) {
184- for (RetryInfo current : dest ) {
183+ private static void addToRetryInfos ( Set < RetryInfo > retryInfos , RetryInfo retryInfo ) {
184+ for (RetryInfo current : retryInfos ) {
185185 if (current .exception .isAssignableFrom (retryInfo .exception )) {
186- addRetryInfo ( retryInfo , current .children );
186+ addToRetryInfos ( current .children , retryInfo );
187187 return ;
188188 }
189189 if (retryInfo .exception .isAssignableFrom (current .exception )) {
190190 retryInfo .children .add (current );
191191 }
192192 }
193- dest .removeAll (retryInfo .children );
194- dest .add (retryInfo );
193+ retryInfos .removeAll (retryInfo .children );
194+ retryInfos .add (retryInfo );
195195 }
196196
197- private static RetryInfo findMostSpecificRetryInfo (Set <RetryInfo > retryInfo ,
197+
198+ private static RetryInfo findMostSpecificRetryInfo (Set <RetryInfo > retryInfos ,
198199 Class <? extends Exception > exception ) {
199- for (RetryInfo current : retryInfo ) {
200+ for (RetryInfo current : retryInfos ) {
200201 if (current .exception .isAssignableFrom (exception )) {
201202 RetryInfo match = findMostSpecificRetryInfo (current .children , exception );
202203 return match == null ? current : match ;
@@ -222,10 +223,10 @@ void verifyCaller(Callable<?> callable) {
222223 Method callMethod = getCallableMethod (callable .getClass ());
223224 for (Class <?> exceptionOrError : callMethod .getExceptionTypes ()) {
224225 Preconditions .checkArgument (Exception .class .isAssignableFrom (exceptionOrError ),
225- "Callable method exceptions must be derived from Exception" );
226+ "Callable method exceptions must be dervied from Exception" );
226227 @ SuppressWarnings ("unchecked" ) Class <? extends Exception > exception =
227228 (Class <? extends Exception >) exceptionOrError ;
228- Preconditions .checkArgument (findMostSpecificRetryInfo (retryInfo , exception ) != null ,
229+ Preconditions .checkArgument (findMostSpecificRetryInfo (retryInfos , exception ) != null ,
229230 "Declared exception '" + exception + "' is not covered by exception handler" );
230231 }
231232 }
@@ -240,16 +241,16 @@ public Set<Class<? extends Exception>> getNonRetriableExceptions() {
240241
241242 boolean shouldRetry (Exception ex ) {
242243 for (Interceptor interceptor : interceptors ) {
243- Interceptor .RetryResult retryResult = interceptor .beforeEval (ex );
244+ Interceptor .RetryResult retryResult = interceptor .shouldRetry (ex );
244245 if (retryResult != null ) {
245246 return retryResult .booleanValue ();
246247 }
247248 }
248- RetryInfo retryInfo = findMostSpecificRetryInfo (this . retryInfo , ex .getClass ());
249+ RetryInfo retryInfo = findMostSpecificRetryInfo (retryInfos , ex .getClass ());
249250 Interceptor .RetryResult retryResult =
250251 retryInfo == null ? Interceptor .RetryResult .ABORT : retryInfo .retry ;
251252 for (Interceptor interceptor : interceptors ) {
252- retryResult = firstNonNull (interceptor .afterEval (ex , retryResult ), retryResult );
253+ retryResult = firstNonNull (interceptor .shouldRetry (ex , retryResult ), retryResult );
253254 }
254255 return retryResult .booleanValue ();
255256 }
0 commit comments