This can be reproduced by one sentence of code:
WebSocket.newBuilder(A_URL, new WebSocket.Listner(){})
.connectTimeout(Duration.ofSeconds(5)).buildAsync().get();
It will immediately throw following exception:
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Millis
at java.time.Duration.get(java.base@9-ea/Duration.java:552)
at java.net.http.WSOpeningHandshake.<init>(java.httpclient@9-ea/WSOpeningHandshake.java:87)
at java.net.http.WS.newInstanceAsync(java.httpclient@9-ea/WS.java:61)
at java.net.http.WSBuilder.buildAsync(java.httpclient@9-ea/WSBuilder.java:103)
If look at the source code of WSOpeningHandshake.java
if (connectTimeout != null) {
requestBuilder.timeout(
TimeUnit.of(ChronoUnit.MILLIS),
connectTimeout.get(ChronoUnit.MILLIS)
);
}
This can be expected based on javadoc of "long java.time.Duration.get(TemporalUnit unit)". Apparently, ChronoUnit.MILLIS is not supported yet.
"
Gets the value of the requested unit.
This returns a value for each of the two supported units, SECONDS and NANOS. All other units throw an exception."
WebSocket.newBuilder(A_URL, new WebSocket.Listner(){})
.connectTimeout(Duration.ofSeconds(5)).buildAsync().get();
It will immediately throw following exception:
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Millis
at java.time.Duration.get(java.base@9-ea/Duration.java:552)
at java.net.http.WSOpeningHandshake.<init>(java.httpclient@9-ea/WSOpeningHandshake.java:87)
at java.net.http.WS.newInstanceAsync(java.httpclient@9-ea/WS.java:61)
at java.net.http.WSBuilder.buildAsync(java.httpclient@9-ea/WSBuilder.java:103)
If look at the source code of WSOpeningHandshake.java
if (connectTimeout != null) {
requestBuilder.timeout(
TimeUnit.of(ChronoUnit.MILLIS),
connectTimeout.get(ChronoUnit.MILLIS)
);
}
This can be expected based on javadoc of "long java.time.Duration.get(TemporalUnit unit)". Apparently, ChronoUnit.MILLIS is not supported yet.
"
Gets the value of the requested unit.
This returns a value for each of the two supported units, SECONDS and NANOS. All other units throw an exception."