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

Jaikiran Pai jpai at openjdk.org
Tue Dec 20 10:33:29 UTC 2022


On Tue, 20 Dec 2022 10:22:19 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Chris Hegarty has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   review comments: 1) remove MAX_INT restriction, and 2) check 0 write
>
> src/java.net.http/share/classes/jdk/internal/net/http/ResponseSubscribers.java line 284:
> 
>> 282:         @Override
>> 283:         public void onNext(List<ByteBuffer> items) {
>> 284:             int size = Utils.remaining(items, Integer.MAX_VALUE);
> 
> Hello Chris, are we intentionally limiting the `max` to `Integer.MAX_VALUE` here? This specific `Utils.remaining` will throw an `IllegalArgumentException` if the total `remaining` content across the `items` exceed that max value. If it is intentional to use this method, should we explicitly handle the `IAE` and rethrow it as `IOException`?

There's an overloaded `Utils.remaining` which doesn't constrain the maximum size. Perhaps we could use that?

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

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


More information about the net-dev mailing list