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

Improve documentation for CompletionException handling

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

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

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: