RFR: 8377796: java.net.http.HttpClient.send() and sendAsync() never complete when BodyHandler.apply() returns null [v2]

Jaikiran Pai jpai at openjdk.org
Fri Feb 13 10:21:19 UTC 2026


On Fri, 13 Feb 2026 09:14:33 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - split the test method arguments into individual parts
>>  - no need for the duplicate null check
>>  - use HttpTestEchoHandler in the new test
>
> src/java.net.http/share/classes/jdk/internal/net/http/MultiExchange.java line 387:
> 
>> 385:         BodySubscriber<T> bs = responseHandler.apply(new ResponseInfoImpl(r.statusCode(),
>> 386:                 r.headers(), r.version()));
>> 387:         Objects.requireNonNull(bs, "BodyHandler returned a null BodySubscriber");
> 
> We might want to revisit that at some point. Instead of throwing would it make more sense to return a `CompletableFuture` that is completed with a `NullPointerException`? Either way we'll need to see how it behaves WRT operation ref count handling...

I'll make a note of it as a future work. I ran into the original issue when trying to untangle the async/CompletableFuture based call path in the MultiExchange. I'll have to refresh myself on what I learnt from those experiments to be able to do a change like this one :)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29691#discussion_r2803444742


More information about the net-dev mailing list