-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8371009: HttpClient javadoc synchronous example missing HttpRequest variable declaration #28084
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
…st variable declaration
|
👋 Welcome back ehs208! A progress list of the required criteria for merging this PR into |
|
@ehs208 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 75 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dfuch, @Michael-Mc-Mahon) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
| * HttpRequest request = HttpRequest.newBuilder() | ||
| * .uri(URI.create("https://foo.com/")) | ||
| * .build(); | ||
| * |
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.
Thanks for working on this patch!
I would put the creation of the request after the creation of the client. Logically you would create the client first.
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.
Thank you for the review!
I’ve updated the example to create the client before the request, as suggested.
| * <p><b>Asynchronous Example</b> | ||
| * {@snippet : | ||
| * HttpRequest request = HttpRequest.newBuilder() | ||
| * .uri(URI.create("https://foo.com/")) | ||
| * .timeout(Duration.ofMinutes(2)) | ||
| * .header("Content-Type", "application/json") | ||
| * .POST(BodyPublishers.ofFile(Paths.get("file.json"))) | ||
| * .build(); | ||
| * client.sendAsync(request, BodyHandlers.ofString()) | ||
| * .thenApply(HttpResponse::body) | ||
| * .thenAccept(System.out::println); } | ||
| * |
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 POST snippet doesn't have the creation of the client, but I believe it's OK because the creation of the client is shown in the snippet just above. In addition, we don't want to seem to promote creating a new client for each new request.
|
@Michael-Mc-Mahon I believe this change doesn't require a CSR since it's just fixing an example. @ehs208 did you generate |
I built the Javadoc locally using The
(Attached is a screenshot from the generated docs:) |
Upon checking again, I noticed that the asynchronous example is indented slightly more than the synchronous one. |
It looks like it's only the first line in the asynchronous example that is misaligned. It would be good to fix it along in this PR. Thanks for catching this. |
Thanks! The indentation fix has been included in the latest commit. |
I agree this is not a spec or behavior change, so should not require a CSR |
|
/integrate |
|
/sponsor |
|
Going to push as commit 973dc3f.
Your commit was automatically rebased without conflicts. |


Fixes JDK-8371009.
The synchronous HttpClient example references
requestwithout defining it.This patch adds a minimal HttpRequest initialization immediately before the
synchronous example (mirroring the asynchronous snippet) so the example
compiles and runs as-is.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28084/head:pull/28084$ git checkout pull/28084Update a local copy of the PR:
$ git checkout pull/28084$ git pull https://git.openjdk.org/jdk.git pull/28084/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28084View PR using the GUI difftool:
$ git pr show -t 28084Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28084.diff
Using Webrev
Link to Webrev Comment