RFR: 8299015: Ensure that HttpResponse.BodySubscribers.ofFile writes all bytes [v3]
Daniel Fuchs
dfuchs at openjdk.org
Tue Dec 20 11:01:52 UTC 2022
On Tue, 20 Dec 2022 10:56:02 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
>> 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.
Ah! Good point...
-------------
PR: https://git.openjdk.org/jdk/pull/11722
More information about the net-dev
mailing list