@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions", "unchecked"}) @Override public long computeSleepTime(Attempt lastAttempt) { if (lastAttempt.hasException()) { Throwable cause = lastAttempt.getException(); if (exceptionClass.isAssignableFrom(cause.getClass())) { return function.apply((T) cause); } } return 0L; } }
@Override public boolean test(Attempt<?> attempt) { return attempt.hasException() && delegate.test(attempt.getException()); } }
@Override public boolean test(Attempt<?> attempt) { return attempt.hasException() && exceptionClass.isAssignableFrom(attempt.getException().getClass()); } }
/** * If the last {@link Attempt} had an Exception, ensure it is available in * the stack trace. * * @param message Exception description to be added to the stack trace * @param attempt what happened the last time we failed */ private RetryException(String message, Attempt<?> attempt) { super(message, attempt.hasException() ? attempt.getException() : null); this.lastFailedAttempt = attempt; }
private void assertExceptionAttempt(Attempt actualAttempt, Class<?> expectedExceptionClass) { assertFalse(actualAttempt.hasResult()); assertTrue(actualAttempt.hasException()); assertTrue(expectedExceptionClass.isInstance(actualAttempt.getException())); }