JDK-8156693 : Improve usability of CompletableFuture use in WebSocket API
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-05-10
  • Updated: 2017-06-28
  • Resolved: 2016-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b123Fixed
Related Reports
Relates :  
Relates :  
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.
Comments
Discussions related to error handling: http://mail.openjdk.java.net/pipermail/net-dev/2016-April/009638.html http://cs.oswego.edu/pipermail/concurrency-interest/2016-May/015125.html
07-06-2016