@Test public void retryingCallbackCallsInitializeAndCleanupUntilSuccess() { callback = LambdaCallback.retrying(this::markInitThenFailIfFewerThatTenInits, this::markCleanup); callback.runWithRetry(initsAndCleanups); assertThat(initsAndCleanups.inits()).isEqualTo(10); assertThat(initsAndCleanups.cleanups()).isEqualTo(9); }
public static <R> Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup); }
LambdaCallback extends Callback<R> { public static <R> Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup); } }
LambdaCallback extends Callback<R> { public static <R> Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup); } private  LambdaCallback(Consumer<R> initialize, BiConsumer<R, Throwable> onInitializationFailure); }
LambdaCallback extends Callback<R> { public static <R> Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup); } private  LambdaCallback(Consumer<R> initialize, BiConsumer<R, Throwable> onInitializationFailure); static Callback<R> singleAttempt(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup); static Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup); static Callback<R> of(Consumer<R> initialize); @Override void init(R resource); @Override void cleanup(R resource, Throwable initFailure); }
LambdaCallback extends Callback<R> { public static <R> Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup); } private  LambdaCallback(Consumer<R> initialize, BiConsumer<R, Throwable> onInitializationFailure); static Callback<R> singleAttempt(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup); static Callback<R> retrying(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup); static Callback<R> of(Consumer<R> initialize); @Override void init(R resource); @Override void cleanup(R resource, Throwable initFailure);  }