-
Couldn't load subscription status.
- Fork 6.1k
8368528: HttpClient.Builder.connectTimeout should accept arbitrarily large values #27973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses following failures:
Caused by: java.lang.ArithmeticException: long overflow
at java.base/java.lang.Math.multiplyExact(Math.java:1036)
at java.base/java.lang.Math.multiplyExact(Math.java:1012)
at java.base/java.time.Duration.toMillis(Duration.java:1243)
at java.net.http/jdk.internal.net.http.HttpQuicConnection$H3QuicConnectionImpl.connectAsync(HttpQuicConnection.java:509)
|
👋 Welcome back vyazici! A progress list of the required criteria for merging this PR into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses two following failures:
Caused by: java.time.DateTimeException: Instant exceeds minimum or maximum instant
at java.base/java.time.Instant.plusSeconds(Instant.java:883)
at java.base/java.time.Instant.plus(Instant.java:856)
at java.base/java.time.Instant.plus(Instant.java:209)
at java.base/java.time.Duration.addTo(Duration.java:1120)
at java.base/java.time.Instant.plus(Instant.java:788)
at java.net.http/jdk.internal.net.http.common.Deadline.plus(Deadline.java:177)
Caused by: java.lang.ArithmeticException: long overflow
at java.base/java.lang.Math.multiplyExact(Math.java:1036)
at java.base/java.time.Instant.millisUntil(Instant.java:1207)
at java.base/java.time.Instant.until(Instant.java:1153)
at java.net.http/jdk.internal.net.http.common.Deadline.until(Deadline.java:200)
|
❗ This change is not yet ready to be integrated. |
| public static final Set<Duration> EXCESSIVE_DURATIONS = Set.of( | ||
| Duration.MAX, | ||
| // This triggers different exceptions than the ones triggered by `Duration.MAX` | ||
| Duration.ofMillis(Long.MAX_VALUE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reproduction by the reporter provides 3 Duration values triggering failures. Above two is sufficient to reproduce all 3 exceptions shared earlier:
plus(Deadline.java:177)until(Deadline.java:200)connectAsync(HttpQuicConnection.java:509)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might soon have saturating addition functionality in java.time.Instant; see: #27549
I note that jdk.internal.net.http.common.Deadline also wants to have saturating subtraction, and I wonder if that's really needed. It seems that the two usages of the minus method in the codebase can be reimplemented alternatively. In which case Deadline could delete minus.
Furthermore, if there's no need for saturating subtraction, do we need the Deadline class? What does it provide, that Instant does not?
Great tip! 💯 I will hold this PR until #27549 gets merged, and use
I also have my reservations regarding the rich, yet seldom used API surface of
In short, |
One problem for this PR is that the proposed Now, I understand that in your case you will never have negative duration, let alone such extremely negative one. But it would still be good to be robust, especially if it also involves less code.
To avoid subtraction, rearrange the terms. Different rearrangements enable different options, but either option is fine:
Okay, so you want your source of ticks to be exclusive and monotonic, neither of which could be guaranteed without introducing a few specialised types. Got it. |
Introduce necessary fixes to address exceptions thrown when excessive
Durations are provided toDuration-acceptingHttpClientpublic APIs.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27973/head:pull/27973$ git checkout pull/27973Update a local copy of the PR:
$ git checkout pull/27973$ git pull https://git.openjdk.org/jdk.git pull/27973/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27973View PR using the GUI difftool:
$ git pr show -t 27973Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27973.diff
Using Webrev
Link to Webrev Comment