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

Improve usability of CompletableFuture use in WebSocket API

    XMLWordPrintable

Details

    • 9
    • b123
    • Verified

    Description

      WebSocket returns CompletableFuture from some of its methods. CFs are used by an implementation to signal when the operation is complete.

      Currently, there is a number of known issues with how it's done. This issues reduce usability of the feature.

      1. Send methods return CompletableFuture<Void> instead of CompletableFuture<WebSocket>. The design was based on a false assumption that WebSocket possibly needed to continue asynchronous operation is always accessible in the same scope where returned CF is used.

      2. Methods specify that CompletableFuture is returned immediately. This is needlessly restrictive for an implementation. It might also give a false impression that the method always dispatches to another thread and returns immediately.

      3. Some methods that return CompletableFuture also throw exceptions. There's some evidence that this aspect actually makes it harder to use such methods for completely async computations.

      Attachments

        Issue Links

          Activity

            People

              prappo Pavel Rappo
              prappo Pavel Rappo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: