Hi,
Thank you for noticing this glitch.
This is indeed something that should be fixed, and such
a change would be welcomed.
If you have a JBS account then please go on and file an issue.
Otherwise you might do it through https://bugreport.java.com/bugreport/
best regards
-- daniel
On 25/10/2025 18:44, 은현수 wrote:
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>