RFR: 8347995: Race condition in jdk/java/net/httpclient/offline/FixedResponseHttpClient.java

Daniel Fuchs dfuchs at openjdk.org
Fri Jan 17 17:05:36 UTC 2025


On Fri, 17 Jan 2025 16:01:27 GMT, Volkan Yazıcı <duke at openjdk.org> wrote:

>> The jdk/java/net/httpclient/offline/FixedResponseHttpClient.java test class makes unreasonable assumptions on BodyPublisher implementation. There's no guarantee that all buffers will be available until the subscriber is completed. 
>> The fix is to way for completion before getting the consumed buffers.
>
> test/jdk/java/net/httpclient/offline/FixedResponseHttpClient.java line 258:
> 
>> 256:         public final CompletableFuture<List<ByteBuffer>> getBuffers() {
>> 257:             return consumed;
>> 258:         }
> 
> Is this method really needed? Above you can replace `subscriber.getBuffers().join()` with `subscriber.consumed.join()` too.

I could have. I preferred calling a method though.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23176#discussion_r1920488032


More information about the net-dev mailing list