RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes [v3]
Daniel Jeliński
djelinski at openjdk.org
Tue Dec 20 10:58:49 UTC 2022
On Tue, 20 Dec 2022 10:34:44 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> I replaced usages with Math::addExact, and generalised the catch to handle arithmetic exceptions too
>
> That's the reason I originally didn't comment on the size limitation to Integer.MAX_VALUE - this is an acceptable limitation and it avoids to have to care about overflows here if size <= Integer.MAX_VALUE. Integer.MAX_VALUE shoudln't be reached in the context where the publisher is the HttpClient.
>
> If we want to allow longs however, we should really use Math.addExact all the way down - including in Utils::remaining.
I don't think we can ever overflow long here; ByteBuffer.remaining can not exceed Integer.MAX_VALUE, and items.toArray cannot create an array with more elements than integer.MAX_VALUE.
-------------
PR: https://git.openjdk.org/jdk/pull/11722
More information about the net-dev
mailing list