-
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
src/java.net.http/share/classes/jdk/internal/net/http/HttpQuicConnection.java
Show resolved
Hide resolved
|
👋 Welcome back vyazici! A progress list of the required criteria for merging this PR into |
src/java.net.http/share/classes/jdk/internal/net/http/common/Deadline.java
Show resolved
Hide resolved
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
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. |
|
I discussed this matter internally with @pavelrappo and @dfuch, and decided to keep the code as is, and not use the recently introduced
|
src/java.net.http/share/classes/jdk/internal/net/http/common/Deadline.java
Show resolved
Hide resolved
src/java.net.http/share/classes/jdk/internal/net/http/common/Deadline.java
Show resolved
Hide resolved
src/java.net.http/share/classes/jdk/internal/net/http/common/Deadline.java
Outdated
Show resolved
Hide resolved
| try { | ||
| return Duration.between(startInclusive.deadline, endExclusive.deadline); | ||
| } catch (DateTimeException | // "Instant exceeds minimum or maximum instant" | ||
| ArithmeticException exception) { // "long overflow" | ||
| // `Deadline` works with `Instant` under the hood. | ||
| // Delta between `Instant.MIN` and `Instant.MAX` fits in a `Duration`. | ||
| // Hence, we should never receive a numeric overflow while calculating the delta between two deadlines. | ||
| throw new IllegalStateException("Unexpected overflow", exception); | ||
| } | ||
| } | ||
|
|
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.
Do we need to change this method? I would just revert them.
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.
Duration#between(Temporal,Temporal) can throw DateTimeException and ArithmeticException, but not in our case due to the reason I elaborated in the comment. In this change, I've removed these two exceptions from the Javadoc, since they cannot happen.
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