- * {@link CffuFactory#toCffu(CompletionStage)} is inverse operation to this method.
- * {@link CffuFactory#cffuArrayUnwrap(Cffu[])} is the batch operation to this method.
- *
- * @return the underlying CompletableFuture
- * @see CffuFactory#toCffu(CompletionStage)
- * @see CffuFactory#cffuArrayUnwrap(Cffu[])
- * @see #toCompletableFuture()
- */
- @Contract(pure = true)
- @SuppressFBWarnings("EI_EXPOSE_REP")
- public CompletableFuture cffuUnwrap() {
- return cf;
- }
-
/**
* Returns the estimated number of Cffus whose completions are awaiting completion of this Cffu.
* This method is designed for use in monitoring system state, not for synchronization control.
@@ -2880,6 +2863,7 @@ public int getNumberOfDependents() {
// - dangerous
// - obtrudeValue(value)
// - obtrudeException(ex)
+ // - cffuUnwrap()
// - for API compatibility of CompletableFuture
// - newIncompleteFuture()
////////////////////////////////////////////////////////////////////////////////
@@ -2916,6 +2900,23 @@ public void obtrudeException(Throwable ex) {
cf.obtrudeException(ex);
}
+ /**
+ * Returns the underlying CompletableFuture.
+ * In general, you should NEVER use this method, use {@link #toCompletableFuture()} instead.
+ *
+ * {@link CffuFactory#cffuArrayUnwrap(Cffu[])} is the batch operation to this method.
+ *
+ * @return the underlying CompletableFuture
+ * @see #toCompletableFuture()
+ * @see CffuFactory#cffuArrayUnwrap(Cffu[])
+ * @see #toCompletableFuture()
+ */
+ @Contract(pure = true)
+ @SuppressFBWarnings("EI_EXPOSE_REP")
+ public CompletableFuture cffuUnwrap() {
+ return cf;
+ }
+
/**
* Returns a new incomplete Cffu with CompletableFuture of the type to be returned by a CompletionStage method.
*
diff --git a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java
index c53a5d43..3f377bff 100644
--- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java
+++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java
@@ -3575,7 +3575,8 @@ public static CompletableFuture runAfterEitherSuccessAsync(
C catching(C cfThis, Class exceptionType, Function super X, ? extends T> fallback) {
requireNonNull(cfThis, "cfThis is null");
requireNonNull(fallback, "fallback is null");
- return (C) cfThis.handle((r, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass()))
+
+ return (C) cfThis.handle((v, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass()))
? cfThis : completedFuture(fallback.apply((X) ex))
).thenCompose(x -> x);
}
@@ -3617,8 +3618,9 @@ C catchingAsync(C cfThis, Class exceptionType, Function super X, ? extends
requireNonNull(cfThis, "cfThis is null");
requireNonNull(fallback, "fallback is null");
requireNonNull(executor, "executor is null");
- return (C) cfThis.handle((r, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass()))
- ? cfThis : cfThis.handleAsync((r1, ex1) -> fallback.apply((X) ex1), executor)
+
+ return (C) cfThis.handle((v, ex) -> (ex == null || !exceptionType.isAssignableFrom(ex.getClass()))
+ ? cfThis : cfThis.handleAsync((v1, ex1) -> fallback.apply((X) ex1), executor)
).thenCompose(x -> x);
}
@@ -3657,8 +3659,8 @@ C exceptionallyAsync(C cfThis, Function fn, Executor exe
return (C) cfThis.exceptionallyAsync(fn, executor);
}
// below code is copied from CompletionStage#exceptionallyAsync
- return (C) cfThis.handle((r, ex) -> (ex == null) ? cfThis :
- cfThis.handleAsync((r1, ex1) -> fn.apply(ex1), executor)
+ return (C) cfThis.handle((v, ex) -> (ex == null) ? cfThis :
+ cfThis.handleAsync((v1, ex1) -> fn.apply(ex1), executor)
).thenCompose(x -> x);
}
@@ -3871,7 +3873,7 @@ private static void completeCf(CompletableFuture