-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8267140: Support closing the HttpClient by making it auto-closable #13019
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
Conversation
|
/csr needed |
|
👋 Welcome back dfuchs! A progress list of the required criteria for merging this PR into |
|
@dfuch has indicated that a compatibility and specification (CSR) request is needed for this pull request. @dfuch please create a CSR request for issue JDK-8267140 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Webrevs
|
|
Here is the CSR draft: https://bugs.openjdk.org/browse/JDK-8304165 |
Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
|
Thanks Andrey @turbanoff for the suggestions. I have applied them. |
|
The latest updated wording to the specification in Overall, the changes in this PR look good to me and I believe the addition of these new APIs will allow applications to control the lifecycle and resources used by the |
test/jdk/java/net/httpclient/offline/FixedResponseHttpClient.java
Outdated
Show resolved
Hide resolved
jaikiran
left a comment
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.
There a couple of trivial typos in comments, which I have noted inline. The OfflineTesting file would need a copyright year update.
Other than that, the latest changes in 6226acf all look good to me.
|
@AlanBateman suggested the following changes, with which I have updated the CSR and this PR: In the class level documentation:
In each of the new methods:
|
|
@dfuch This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
|
Hello Daniel, the latest documentation changes all look fine to me. As for:
I haven't previously used this construct in a |
|
/integrate |
yes - I have generated the api doc and it looks fine |
|
Going to push as commit 6580c4e. |
Please find here an RFE that makes the
java.net.HttpClientauto-closeable.The API has been modeled on
ExecutorService.HttpClient::close() is a graceful shutdown and will wait until all operations are terminated before returning.
If a request is in progress, and the caller doesn't pull the corresponding data (for instance, the request was sent with a BodyHandler.ofInputStream(), but the caller stopped reading the input stream) then close() may never return.
Therefore, additional methods similar to those present in
ExecutorServiceare also proposed. In summary:shutdown(): initiate a graceful shutdown, but doesn't wait for termination.shutdownNow(): initiate an immediate shutdown, attempting to cancel all operations in progress. Doesn't wait for termination.awaitTermination(Duration): await for termination within the given delayisTerminated()tells whether the client is terminatedNew tests have been added to test the proposed behaviors.
HttpClient tests (new and old) are still stable.
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13019/head:pull/13019$ git checkout pull/13019Update a local copy of the PR:
$ git checkout pull/13019$ git pull https://git.openjdk.org/jdk.git pull/13019/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13019View PR using the GUI difftool:
$ git pr show -t 13019Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13019.diff
Webrev
Link to Webrev Comment