RFR: 8371009: HttpClient javadoc synchronous example missing HttpRequest variable declaration [v2]

Daniel Fuchs dfuchs at openjdk.org
Fri Oct 31 15:26:15 UTC 2025


On Fri, 31 Oct 2025 12:58:39 GMT, EunHyunsu <duke at openjdk.org> wrote:

>> Fixes JDK-8371009.
>> 
>> The synchronous HttpClient example references `request` without 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.
>
> EunHyunsu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Apply review suggestion: create client before request in HttpClient example

src/java.net.http/share/classes/java/net/http/HttpClient.java line 124:

> 122:  *        .thenApply(HttpResponse::body)
> 123:  *        .thenAccept(System.out::println);  }
> 124:  *

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.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28084#discussion_r2481792322


More information about the net-dev mailing list