Missing HttpRequest variable in HttpClient javadoc synchronous example
은현수
ehs122100 at gmail.com
Sat Oct 25 17:44:49 UTC 2025
Dear maintainers,
I noticed a small issue in the HttpClient Javadoc that could confuse developers using the synchronous example.
In HttpClient.java (lines 96–107), the synchronous example references an undefined request variable:
HttpClient client = HttpClient.newBuilder()
.version(Version.HTTP_1_1)
.followRedirects(Redirect.NORMAL)
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
// ^^^^^ 'request' is not defined
However, the asynchronous example immediately below (lines 111–119) correctly shows the HttpRequest creation:
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://foo.com/"))
.build();
This discrepancy would cause a compilation error if someone copies the synchronous example directly.
I’d like to suggest adding the missing HttpRequest declaration to make the example complete and executable.
Would this change be acceptable?
Should I file a JBS issue for it?
Thank you,
Hyunsu Eun
GitHub: ehs208 <https://github.com/ehs208>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/net-dev/attachments/20251026/9d8ca5b9/attachment.htm>
More information about the net-dev
mailing list