22
22
import com .mongodb .lang .Nullable ;
23
23
24
24
import java .util .Optional ;
25
- import java .util .function .BiFunction ;
26
25
import java .util .function .BiPredicate ;
26
+ import java .util .function .BinaryOperator ;
27
27
import java .util .function .Supplier ;
28
28
29
29
import static com .mongodb .assertions .Assertions .assertFalse ;
@@ -110,9 +110,9 @@ public RetryState() {
110
110
* </ul>
111
111
* The exception thrown represents the failed result of the associated retryable activity,
112
112
* i.e., the caller must not do any more attempts.
113
- * @see #advanceOrThrow(Throwable, BiFunction , BiPredicate)
113
+ * @see #advanceOrThrow(Throwable, BinaryOperator , BiPredicate)
114
114
*/
115
- void advanceOrThrow (final RuntimeException attemptException , final BiFunction < Throwable , Throwable , Throwable > exceptionTransformer ,
115
+ void advanceOrThrow (final RuntimeException attemptException , final BinaryOperator < Throwable > exceptionTransformer ,
116
116
final BiPredicate <RetryState , Throwable > retryPredicate ) throws RuntimeException {
117
117
try {
118
118
doAdvanceOrThrow (attemptException , exceptionTransformer , retryPredicate , true );
@@ -127,9 +127,9 @@ void advanceOrThrow(final RuntimeException attemptException, final BiFunction<Th
127
127
* This method is intended to be used by code that generally handles all {@link Throwable} types explicitly,
128
128
* which is usually asynchronous code.
129
129
*
130
- * @see #advanceOrThrow(RuntimeException, BiFunction , BiPredicate)
130
+ * @see #advanceOrThrow(RuntimeException, BinaryOperator , BiPredicate)
131
131
*/
132
- void advanceOrThrow (final Throwable attemptException , final BiFunction < Throwable , Throwable , Throwable > exceptionTransformer ,
132
+ void advanceOrThrow (final Throwable attemptException , final BinaryOperator < Throwable > exceptionTransformer ,
133
133
final BiPredicate <RetryState , Throwable > retryPredicate ) throws Throwable {
134
134
doAdvanceOrThrow (attemptException , exceptionTransformer , retryPredicate , false );
135
135
}
@@ -140,7 +140,7 @@ void advanceOrThrow(final Throwable attemptException, final BiFunction<Throwable
140
140
* as {@link RetryState} does not have any source of {@link Exception}s.
141
141
*/
142
142
private void doAdvanceOrThrow (final Throwable attemptException ,
143
- final BiFunction < Throwable , Throwable , Throwable > exceptionTransformer ,
143
+ final BinaryOperator < Throwable > exceptionTransformer ,
144
144
final BiPredicate <RetryState , Throwable > retryPredicate ,
145
145
final boolean onlyRuntimeExceptions ) throws Throwable {
146
146
assertTrue (attempt () < attempts );
@@ -166,10 +166,10 @@ private void doAdvanceOrThrow(final Throwable attemptException,
166
166
}
167
167
168
168
/**
169
- * @param onlyRuntimeExceptions See {@link #doAdvanceOrThrow(Throwable, BiFunction , BiPredicate, boolean)}.
169
+ * @param onlyRuntimeExceptions See {@link #doAdvanceOrThrow(Throwable, BinaryOperator , BiPredicate, boolean)}.
170
170
*/
171
171
private static Throwable transformException (@ Nullable final Throwable previouslyChosenException , final Throwable attemptException ,
172
- final boolean onlyRuntimeExceptions , final BiFunction < Throwable , Throwable , Throwable > exceptionTransformer ) {
172
+ final boolean onlyRuntimeExceptions , final BinaryOperator < Throwable > exceptionTransformer ) {
173
173
if (onlyRuntimeExceptions && previouslyChosenException != null ) {
174
174
assertTrue (isRuntime (previouslyChosenException ));
175
175
}
@@ -194,7 +194,7 @@ private static Throwable transformException(@Nullable final Throwable previously
194
194
195
195
/**
196
196
* @param readOnlyRetryState Must not be mutated by this method.
197
- * @param onlyRuntimeExceptions See {@link #doAdvanceOrThrow(Throwable, BiFunction , BiPredicate, boolean)}.
197
+ * @param onlyRuntimeExceptions See {@link #doAdvanceOrThrow(Throwable, BinaryOperator , BiPredicate, boolean)}.
198
198
*/
199
199
private boolean shouldRetry (final RetryState readOnlyRetryState , final Throwable attemptException , final Throwable newlyChosenException ,
200
200
final boolean onlyRuntimeExceptions , final BiPredicate <RetryState , Throwable > retryPredicate ) {
@@ -227,7 +227,7 @@ private static boolean isRuntime(@Nullable final Throwable exception) {
227
227
* by the caller to complete the ongoing attempt.
228
228
* <p>
229
229
* If this method is called from
230
- * {@linkplain RetryingSyncSupplier#RetryingSyncSupplier(RetryState, BiFunction , BiPredicate, Supplier)
230
+ * {@linkplain RetryingSyncSupplier#RetryingSyncSupplier(RetryState, BinaryOperator , BiPredicate, Supplier)
231
231
* retry predicate / failed result transformer}, the behavior is unspecified.
232
232
*
233
233
* @param predicate {@code true} iff retrying needs to be broken.
@@ -265,7 +265,7 @@ public void breakAndThrowIfRetryAnd(final Supplier<Boolean> predicate) throws Ru
265
265
* but instead of throwing an exception, it relays it to the {@code callback}.
266
266
* <p>
267
267
* If this method is called from
268
- * {@linkplain RetryingAsyncCallbackSupplier#RetryingAsyncCallbackSupplier(RetryState, BiFunction , BiPredicate, com.mongodb.internal.async.function. AsyncCallbackSupplier)
268
+ * {@linkplain RetryingAsyncCallbackSupplier#RetryingAsyncCallbackSupplier(RetryState, BinaryOperator , BiPredicate, AsyncCallbackSupplier)
269
269
* retry predicate / failed result transformer}, the behavior is unspecified.
270
270
*
271
271
* @return {@code true} iff the {@code callback} was completed, which happens in the same situations in which
0 commit comments