@Test(expected = NonRetryableException.class) public void testFailureWithNonRetryableFailure() { new RetryingFunction<>(this::failCompletely, RetryableException.class, 2, 10).apply(null); }
@SuppressWarnings("squid:S1181") @Override public V apply(U input) { int retryAttempts = 0; while (true) { try { return baseFunction.apply(input); } catch (Throwable t) { if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) { Throwables.propagate(t); } Tools.randomDelay(maxDelayBetweenRetries); retryAttempts++; } } }
RetryingFunction implements Function<U, V> { @SuppressWarnings("squid:S1181") @Override public V apply(U input) { int retryAttempts = 0; while (true) { try { return baseFunction.apply(input); } catch (Throwable t) { if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) { Throwables.propagate(t); } Tools.randomDelay(maxDelayBetweenRetries); retryAttempts++; } } } }
RetryingFunction implements Function<U, V> { @SuppressWarnings("squid:S1181") @Override public V apply(U input) { int retryAttempts = 0; while (true) { try { return baseFunction.apply(input); } catch (Throwable t) { if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) { Throwables.propagate(t); } Tools.randomDelay(maxDelayBetweenRetries); retryAttempts++; } } } RetryingFunction(Function<U, V> baseFunction,
            Class<? extends Throwable> exceptionClass,
            int maxRetries,
            int maxDelayBetweenRetries); }
RetryingFunction implements Function<U, V> { @SuppressWarnings("squid:S1181") @Override public V apply(U input) { int retryAttempts = 0; while (true) { try { return baseFunction.apply(input); } catch (Throwable t) { if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) { Throwables.propagate(t); } Tools.randomDelay(maxDelayBetweenRetries); retryAttempts++; } } } RetryingFunction(Function<U, V> baseFunction,
            Class<? extends Throwable> exceptionClass,
            int maxRetries,
            int maxDelayBetweenRetries); @SuppressWarnings("squid:S1181") // Yes we really do want to catch Throwable @Override V apply(U input); }
RetryingFunction implements Function<U, V> { @SuppressWarnings("squid:S1181") @Override public V apply(U input) { int retryAttempts = 0; while (true) { try { return baseFunction.apply(input); } catch (Throwable t) { if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) { Throwables.propagate(t); } Tools.randomDelay(maxDelayBetweenRetries); retryAttempts++; } } } RetryingFunction(Function<U, V> baseFunction,
            Class<? extends Throwable> exceptionClass,
            int maxRetries,
            int maxDelayBetweenRetries); @SuppressWarnings("squid:S1181") // Yes we really do want to catch Throwable @Override V apply(U input);  }