RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes [v3]
Chris Hegarty
chegar at openjdk.org
Tue Dec 20 10:42:27 UTC 2022
On Tue, 20 Dec 2022 10:25:18 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> 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/ResponseSubscribers.java line 289:
>
>> 287: ByteBuffer[] buffers = items.toArray(Utils.EMPTY_BB_ARRAY);
>> 288: while (bytesWritten < size) {
>> 289: bytesWritten += out.write(buffers);
>
> Should we handle the potential case of long value overflow, after addition here, which could then cause the while loop to misbehave?
I replaced usages with Math::addExact, and generalised the catch to handle arithmetic exceptions too
-------------
PR: https://git.openjdk.org/jdk/pull/11722
More information about the net-dev
mailing list