RFR: 8368249: HttpClient: Translate exceptions thrown by sendAsync [v5]

Jaikiran Pai jpai at openjdk.org
Wed Oct 22 12:13:32 UTC 2025


On Thu, 16 Oct 2025 05:37:45 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Ensure `HttpClient::sendAsync` translates every operational failure to an `IOException` as per specification.
>> 
>> `tier1-2` passes with the proposed changes.
>> 
>> **Context:** The parent issue, [JDK-8364733], reports that `HttpClient::sendAsync` leaks exceptions which do not extend from `IOException`, and this violates the method's specification. The [JDK-8367067] (#26876) sub-task improved issues around exceptions thrown by request body publishers – which triggered the first encounter with this problem. This PR (and its associated sub-task) is aimed to end this saga.
>> 
>> [JDK-8364733]: https://bugs.openjdk.org/browse/JDK-8364733
>> [JDK-8367067]: https://bugs.openjdk.org/browse/JDK-8367067
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Revert `AbstractThrowingPublishers` changes

test/jdk/java/net/httpclient/HttpClientSendAsyncExceptionTest.java line 72:

> 70:             var request = HttpRequest.newBuilder(URI.create("https://example.com")).GET().build();
> 71:             var responseBodyHandler = HttpResponse.BodyHandlers.discarding();
> 72:             client.sendAsync(request, responseBodyHandler).get();

Nit - it doesn't matter much in this code, but it's usually better to limit the code to the specific call that is expected to throw the expected exception type. That would mean moving out everything except the `Future.get()` call from the lambda.

Same comment for the code in the other test methods too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27787#discussion_r2451875566


More information about the net-dev mailing list