FrankChen021 commented on code in PR #19818:
URL: https://github.com/apache/druid/pull/19818#discussion_r3914095368
##########
processing/src/main/java/org/apache/druid/java/util/http/client/io/AppendableByteArrayInputStream.java:
##########
@@ -168,12 +169,12 @@ private long scanThroughBytesAndDoSomething(long
numToScan, Doer doer) throws IO
final long numToPullFromCurr = Math.min(curr.length - currIndex,
numToScan - numScanned);
doer.doSomethingWithByteArray((int) numToPullFromCurr);
numScanned += numToPullFromCurr;
- currIndex += numToPullFromCurr;
+ currIndex = Math.addExact(currIndex,
Ints.checkedCast(numToPullFromCurr));
numPulled += numToPullFromCurr;
}
synchronized (singleByteReaderDoer) {
- available -= numPulled;
+ available = Math.subtractExact(available, Ints.checkedCast(numPulled));
Review Comment:
[P2] Large skip narrows long byte count to int
skip(long) can consume more than Integer.MAX_VALUE bytes, but numPulled is
narrowed with Ints.checkedCast before updating availability. With multiple
queued chunks exceeding 2 GiB, this throws after bytes were already consumed
and prevents the skip from completing. Keep the accounting long, or update the
int availability counter incrementally/safely.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]