Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8172177

Improve documentation for CompletionException handling

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs

      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);
      });

            dl Doug Lea
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: