private static RetryInfo findMostSpecificRetryInfo( Set<RetryInfo> retryInfo, Class<? extends Exception> exception) { for (RetryInfo current : retryInfo) { if (current.exception.isAssignableFrom(exception)) { RetryInfo match = findMostSpecificRetryInfo(current.children, exception); return match == null ? current : match; } } return null; }
void verifyCaller(Callable<?> callable) { Method callMethod = getCallableMethod(callable.getClass()); for (Class<?> exceptionOrError : callMethod.getExceptionTypes()) { Preconditions.checkArgument( Exception.class.isAssignableFrom(exceptionOrError), "Callable method exceptions must be derived from Exception"); @SuppressWarnings("unchecked") Class<? extends Exception> exception = (Class<? extends Exception>) exceptionOrError; Preconditions.checkArgument( findMostSpecificRetryInfo(retryInfo, exception) != null, "Declared exception '" + exception + "' is not covered by exception handler"); } }
@Override public boolean shouldRetry(Throwable prevThrowable, Object prevResponse) { if (!(prevThrowable instanceof Exception)) { return false; } Exception ex = (Exception) prevThrowable; for (Interceptor interceptor : interceptors) { Interceptor.RetryResult retryResult = checkNotNull(interceptor.beforeEval(ex)); if (retryResult != Interceptor.RetryResult.CONTINUE_EVALUATION) { return retryResult == Interceptor.RetryResult.RETRY; } } RetryInfo retryInfo = findMostSpecificRetryInfo(this.retryInfo, ex.getClass()); Interceptor.RetryResult retryResult = retryInfo == null ? Interceptor.RetryResult.NO_RETRY : retryInfo.retry; for (Interceptor interceptor : interceptors) { Interceptor.RetryResult interceptorRetry = checkNotNull(interceptor.afterEval(ex, retryResult)); if (interceptorRetry != Interceptor.RetryResult.CONTINUE_EVALUATION) { retryResult = interceptorRetry; } } return retryResult == Interceptor.RetryResult.RETRY; }
private static RetryInfo findMostSpecificRetryInfo( Set<RetryInfo> retryInfo, Class<? extends Exception> exception) { for (RetryInfo current : retryInfo) { if (current.exception.isAssignableFrom(exception)) { RetryInfo match = findMostSpecificRetryInfo(current.children, exception); return match == null ? current : match; } } return null; }
private static RetryInfo findMostSpecificRetryInfo(Set<RetryInfo> retryInfo, Class<? extends Exception> exception) { for (RetryInfo current : retryInfo) { if (current.exception.isAssignableFrom(exception)) { RetryInfo match = findMostSpecificRetryInfo(current.children, exception); return match == null ? current : match; } } return null; }
void verifyCaller(Callable<?> callable) { Method callMethod = getCallableMethod(callable.getClass()); for (Class<?> exceptionOrError : callMethod.getExceptionTypes()) { Preconditions.checkArgument(Exception.class.isAssignableFrom(exceptionOrError), "Callable method exceptions must be derived from Exception"); @SuppressWarnings("unchecked") Class<? extends Exception> exception = (Class<? extends Exception>) exceptionOrError; Preconditions.checkArgument(findMostSpecificRetryInfo(retryInfo, exception) != null, "Declared exception '" + exception + "' is not covered by exception handler"); } }
void verifyCaller(Callable<?> callable) { Method callMethod = getCallableMethod(callable.getClass()); for (Class<?> exceptionOrError : callMethod.getExceptionTypes()) { Preconditions.checkArgument( Exception.class.isAssignableFrom(exceptionOrError), "Callable method exceptions must be derived from Exception"); @SuppressWarnings("unchecked") Class<? extends Exception> exception = (Class<? extends Exception>) exceptionOrError; Preconditions.checkArgument( findMostSpecificRetryInfo(retryInfo, exception) != null, "Declared exception '" + exception + "' is not covered by exception handler"); } }
boolean shouldRetry(Exception ex) { for (Interceptor interceptor : interceptors) { Interceptor.RetryResult retryResult = checkNotNull(interceptor.beforeEval(ex)); if (retryResult != Interceptor.RetryResult.CONTINUE_EVALUATION) { return retryResult == Interceptor.RetryResult.RETRY; } } RetryInfo retryInfo = findMostSpecificRetryInfo(this.retryInfo, ex.getClass()); Interceptor.RetryResult retryResult = retryInfo == null ? Interceptor.RetryResult.NO_RETRY : retryInfo.retry; for (Interceptor interceptor : interceptors) { Interceptor.RetryResult interceptorRetry = checkNotNull(interceptor.afterEval(ex, retryResult)); if (interceptorRetry != Interceptor.RetryResult.CONTINUE_EVALUATION) { retryResult = interceptorRetry; } } return retryResult == Interceptor.RetryResult.RETRY; }
@Override public boolean shouldRetry(Throwable prevThrowable, Object prevResponse) { if (!(prevThrowable instanceof Exception)) { return false; } Exception ex = (Exception) prevThrowable; for (Interceptor interceptor : interceptors) { Interceptor.RetryResult retryResult = checkNotNull(interceptor.beforeEval(ex)); if (retryResult != Interceptor.RetryResult.CONTINUE_EVALUATION) { return retryResult == Interceptor.RetryResult.RETRY; } } RetryInfo retryInfo = findMostSpecificRetryInfo(this.retryInfo, ex.getClass()); Interceptor.RetryResult retryResult = retryInfo == null ? Interceptor.RetryResult.NO_RETRY : retryInfo.retry; for (Interceptor interceptor : interceptors) { Interceptor.RetryResult interceptorRetry = checkNotNull(interceptor.afterEval(ex, retryResult)); if (interceptorRetry != Interceptor.RetryResult.CONTINUE_EVALUATION) { retryResult = interceptorRetry; } } return retryResult == Interceptor.RetryResult.RETRY; }