-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
None
In CompletableFuture and CompletionStage javadocs, it should be made clearer when a CompletionException may need to be unwrapped when obtained and when it should be wrapped when thrown. In method handle, both problems arise:
f.handle((v, ex) -> {
// ex may or may not be CompletionException
Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex;
...
// wrap in CompletionException, if necessary, to rethrow
throw (ex instanceof CompletionException) ? (CompletionException) ex : new CompletionException(ex);
});
f.handle((v, ex) -> {
// ex may or may not be CompletionException
Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex;
...
// wrap in CompletionException, if necessary, to rethrow
throw (ex instanceof CompletionException) ? (CompletionException) ex : new CompletionException(ex);
});
- links to
-
Review(master) openjdk/jdk/25880