Skip to content

Commit 34a38f6

Browse files
committed
Improve javadocs wrt FailurePolicy exception handling conditions
1 parent ad163c1 commit 34a38f6

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626

2727
/**
2828
* A Policy that captures conditions to determine whether an execution is a failure.
29-
* <p>
30-
* By default, if no handlers are configured, the execution is considered a failure if an Exception was thrown. If
31-
* multuple handlers are configured, they are logically OR'ed.
32-
* </p>
29+
* <ul>
30+
* <li>By default, any exception is considered a failure and will be handled by the policy. You can override this by
31+
* specifying your own {@code handle} conditions. The default exception handling condition will only be overridden by
32+
* another condition that handles failure exceptions such as {@link #handle(Class)} or {@link #handleIf(BiPredicate)}.
33+
* Specifying a condition that only handles results, such as {@link #handleResult(Object)} or
34+
* {@link #handleResultIf(Predicate)} will not replace the default exception handling condition.</li>
35+
* <li>If multiple {@code handle} conditions are specified, any condition that matches an execution result or failure
36+
* will trigger policy handling.</li>
37+
* </ul>
3338
*
3439
* @param <S> self type
3540
* @param <R> result type

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@
3232

3333
/**
3434
* A policy that defines when retries should be performed.
35-
*
36-
* <p>
37-
* The {@code handle} methods describe when a retry should be performed for a particular failure. The {@code
38-
* handleResult} methods describe when a retry should be performed for a particular result. If multiple {@code handle}
39-
* or {@code handleResult} conditions are specified, any matching condition can allow a retry. The {@code abortOn},
40-
* {@code abortWhen} and {@code abortIf} methods describe when retries should be aborted.
35+
* <ul>
36+
* <li>By default, a RetryPolicy will retry up to {@code 2} times when any {@code Exception} is thrown, with no delay
37+
* between retry attempts.</li>
38+
* <li>You can change the default number of retry attempts and delay between retries by using the {@code with}
39+
* configuration methods.</li>
40+
* <li>You can change the default {@code Exception} handling behavior by specifying
41+
* your own {@code handle} conditions. The default exception handling condition will only be overridden by
42+
* another condition that handles failure exceptions such as {@link #handle(Class)} or {@link #handleIf(BiPredicate)}.
43+
* Specifying a condition that only handles results, such as {@link #handleResult(Object)} or
44+
* {@link #handleResultIf(Predicate)} will not replace the default exception handling condition.</li>
45+
* <li>If multiple {@code handle} conditions are specified, any condition that matches an execution result or failure
46+
* can cause a retry.</li>
47+
* <li>The {@code abortOn}, {@code abortWhen} and {@code abortIf} methods describe when retries should be aborted.</li>
48+
* </ul>
4149
* <p>
4250
* Note: RetryPolicy extends {@link DelayablePolicy} and {@link FailurePolicy} which offer additional configuration.
4351
* </p>

0 commit comments

Comments
 (0)