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>

Reply via email to