-
Type:
CSR
-
Resolution: Approved
-
Priority:
P2
-
None
-
Component/s: core-libs
-
minimal
-
Java API
-
SE
Summary
A number of small specification clarifications and rewordings to supplement the already approved HTTP Client, JDK-8197565.
Problem
Feedback from a number of sources including, JCK, both internal and external engineers, have identified:
-
a number of small deficiencies in the specification that require clarification, and
-
opportunities to simplify the API by removing a superfluous public type and enum value, and
-
opportunities to reword certain targeted sections of text, mainly in WebSocket, to avoid ambiguity thus avoiding misunderstanding.
Solution
-
From
HttpClient.RedirectremoveSAME_PROTOCOLandSECURE. Replace withNORMAL. Leaving{ ALWAYS, NORMAL, NEVER }. It has been observed that the previously namedSECUREwas not really appropriately named and should be renamed toNORMAL, since it will likely be suitable for most normal cases. Given the newly named, aforementioned,NORMAL,SAME_PROTOCOLappears oddly named, possibly confusing, and not likely to be used. -
Remove
WebSocket.MessagePart. This enum was used on the the receiving side to indicate whether the delivery of message was complete, or not. It is asymmetric with the sending side, which uses a simplebooleanfor this purpose. Additionally, it has been observed that handling received messages with a simple boolean significantly reduces and simplifies the receiving code logic. Determination of messages being delivered as a WHOLE, one of the benefits and the main purposes for the aforementionedMessagePart, has proved to not carry its own weight. Note: as part of this review,MessagePart, and variants thereof, have been considered and dismissed, on the sending side, as they obstruct one of the most common patterns of iterating over data and sending it as chunks. -
Throughout the
WebSocketdocumentation care has been taken to avoid ambiguity between websocket messages and the number of invocations of theWebSocket.Listener. The number of messages may not equal the number of listener invocations, as partial messages may be delivered. This has been a source of confusion when folk first start using the API. -
WebSocket does not ( for good reasons ) use the Java SE reactive-stream support in
java.util.concurrent.Flow, but itsrequest( invocation demand ) is heavily influenced by it, and the API can be used to build higher-level Flow's using such. This concept, since analogous toFlow(SubscriberandSubscription), has been clarified. These changes touch a lot of documentation, but it has not changed semantically. -
The WebSocket specification around closure has been tightened up and several corner cases clarified. Again, this touches many parts of the spec, but has not changed significantly.
-
Outbound data flow, in the WebSocket API, is pressured by CompletableFutures returned by the
sendBinaryandsendTextmethods. Equivalent have been added to the less-data drivensendPingandsendPongmethods to prevent outbound saturation. -
The WebSocket API throws
NullPointerExceptiondirectly from methods where a null value is passed, but completes exceptionally returned CompletableFutures in almost all other cases. This is a decision that was made to simplify and streamline error handling. TheHttpClientAPI exposes significantly less CompletableFutures, typically just a singleCFfromsendAsync, which results in less burdensome error handling, therefore throws ( rather than completes exceptionally ) when illegal arguments are passed.
Specification
Specdiff in attached zip file, or browsable online at: http://cr.openjdk.java.net/~chegar/httpclient/supplementary/overview-summary.html
- csr of
-
JDK-8199938 Supplementary minor HTTP Client spec clarifications
-
- Resolved
-