Improve documentation for CompletionException handling

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 26
    • Affects Version/s: None
    • Component/s: 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);
      });

            Assignee:
            Doug Lea
            Reporter:
            Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: