RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes [v3]

Daniel Fuchs dfuchs at openjdk.org
Tue Dec 20 10:50:55 UTC 2022


On Tue, 20 Dec 2022 10:42:27 GMT, Chris Hegarty <chegar at openjdk.org> wrote:

>> The implementation of `BodySubscribers.ofFile` does not correctly handle the case of a short gathering write. The write should be retried until all the bytes have been written to the underlying file.
>> 
>> This is generally not an issue that would occur very frequently, since the `IOV_MAX` is commonly 1024 on Mac/Linux, and 16 on Windows. However, it is clearly a bug, and should be fixed.
>
> Chris Hegarty has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - move into the try
>  - use Math::addExact

src/java.net.http/share/classes/jdk/internal/net/http/common/Utils.java line 671:

> 669:         long remain = 0;
> 670:         for (ByteBuffer buf : bufs) {
> 671:             remain = Math.addExact(remain, buf.remaining());

There's another occurrence at line 655

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

PR: https://git.openjdk.org/jdk/pull/11722


More information about the net-dev mailing list