RFR: 8368249: HttpClient: Translate exceptions thrown by sendAsync

Daniel Fuchs dfuchs at openjdk.org
Tue Oct 14 14:33:09 UTC 2025


On Tue, 14 Oct 2025 07:21:21 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

src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java line 1145:

> 1143:                                 || exception instanceof ExecutionException
> 1144:                                 ? exception.getCause()
> 1145:                                 : exception;

Suggestion:

                        var unwrappedException = Utils.getCompletionCause(exception);

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

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


More information about the net-dev mailing list