Skip to content

Commit 7a92886

Browse files
committed
Update event listener javadocs
Updates event listener javadocs to more clearly indicate that exceptions are suppressed, and that Fallbacks should be used to provide alternative results.
1 parent edf0b5e commit 7a92886

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/main/java/net/jodah/failsafe/FailsafeExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
* <p>
3636
* Async executions are run by default on the {@link ForkJoinPool#commonPool()}. Alternative executors can be configured
3737
* via {@link #with(ScheduledExecutorService)} and similar methods. All async executions are cancellable and
38-
* interruptable via the returned CompletableFuture, even those run by a {@link ForkJoinPool} or {@link CompletionStage}.
38+
* interruptable via the returned CompletableFuture, even those run by a {@link ForkJoinPool} or {@link
39+
* CompletionStage}.
3940
*
4041
* @param <R> result type
4142
* @author Jonathan Halterman
@@ -292,7 +293,8 @@ public FailsafeExecutor<R> onComplete(CheckedConsumer<? extends ExecutionComplet
292293
/**
293294
* Registers the {@code listener} to be called when an execution fails. If multiple policies, are configured, this
294295
* handler is called when execution is complete and <i>any</i> policy fails.
295-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
296+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
297+
* result for a failed execution, use a {@link Fallback}.</p>
296298
*/
297299
@Override
298300
public FailsafeExecutor<R> onFailure(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {

src/main/java/net/jodah/failsafe/PolicyListeners.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class PolicyListeners<S, R> {
3636
* Registers the {@code listener} to be called when a {@link Policy} fails to handle an execution. This means that not
3737
* only was the supplied execution considered a failure by the policy, but that the policy was unable to produce a
3838
* successful result.
39+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
40+
* result for a failed execution, use a {@link Fallback}.</p>
3941
*/
4042
public S onFailure(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
4143
failureListener = EventListener.of(Assert.notNull(listener, "listener"));
@@ -45,6 +47,7 @@ public S onFailure(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listene
4547
/**
4648
* Registers the {@code listener} to be called when a {@link Policy} succeeds in handling an execution. This means
4749
* that the supplied execution either succeeded, or if it failed, the policy was able to produce a successful result.
50+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
4851
*/
4952
public S onSuccess(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
5053
successListener = EventListener.of(Assert.notNull(listener, "listener"));

src/main/java/net/jodah/failsafe/RetryPolicy.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ public boolean isAbortable(R result, Throwable failure) {
223223

224224
/**
225225
* Registers the {@code listener} to be called when an execution is aborted.
226-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
226+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
227+
* result for a failed execution, use a {@link Fallback}.</p>
227228
*/
228229
public RetryPolicy<R> onAbort(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
229230
abortListener = EventListener.of(Assert.notNull(listener, "listener"));
@@ -234,7 +235,8 @@ public RetryPolicy<R> onAbort(CheckedConsumer<? extends ExecutionCompletedEvent<
234235
* Registers the {@code listener} to be called when an execution attempt fails. You can also use {@link
235236
* #onFailure(CheckedConsumer) onFailure} to determine when the execution attempt fails <i>and</i> and all retries
236237
* have failed.
237-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
238+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
239+
* result for a failed execution, use a {@link Fallback}.</p>
238240
*/
239241
public RetryPolicy<R> onFailedAttempt(CheckedConsumer<? extends ExecutionAttemptedEvent<R>> listener) {
240242
failedAttemptListener = EventListener.ofAttempt(Assert.notNull(listener, "listener"));
@@ -244,7 +246,8 @@ public RetryPolicy<R> onFailedAttempt(CheckedConsumer<? extends ExecutionAttempt
244246
/**
245247
* Registers the {@code listener} to be called when an execution fails and the {@link RetryPolicy#withMaxRetries(int)
246248
* max retry attempts} or {@link RetryPolicy#withMaxDuration(Duration) max duration} are exceeded.
247-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
249+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
250+
* result for a failed execution, use a {@link Fallback}.</p>
248251
*/
249252
public RetryPolicy<R> onRetriesExceeded(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
250253
retriesExceededListener = EventListener.of(Assert.notNull(listener, "listener"));
@@ -253,7 +256,8 @@ public RetryPolicy<R> onRetriesExceeded(CheckedConsumer<? extends ExecutionCompl
253256

254257
/**
255258
* Registers the {@code listener} to be called when a retry is about to be attempted.
256-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
259+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
260+
* result for a failed execution, use a {@link Fallback}.</p>
257261
*/
258262
public RetryPolicy<R> onRetry(CheckedConsumer<? extends ExecutionAttemptedEvent<R>> listener) {
259263
retryListener = EventListener.ofAttempt(Assert.notNull(listener, "listener"));
@@ -263,7 +267,8 @@ public RetryPolicy<R> onRetry(CheckedConsumer<? extends ExecutionAttemptedEvent<
263267
/**
264268
* Registers the {@code listener} to be called when a retry is about to be scheduled. A retry will actually be
265269
* performed after any scheduled delay.
266-
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored.</p>
270+
* <p>Note: Any exceptions that are thrown from within the {@code listener} are ignored. To provide an alternative
271+
* result for a failed execution, use a {@link Fallback}.</p>
267272
*/
268273
public RetryPolicy<R> onRetryScheduled(CheckedConsumer<? extends ExecutionScheduledEvent<R>> listener) {
269274
retryScheduledListener = EventListener.ofScheduled(Assert.notNull(listener, "listener"));

0 commit comments

Comments
 (0)