Copilot commented on code in PR #3865:
URL: https://github.com/apache/avro/pull/3865#discussion_r3567559224
##########
lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java:
##########
@@ -364,7 +400,7 @@ protected Object readMap(Object old, Schema expected,
ResolvingDecoder in) throw
LogicalType logicalType = eValue.getLogicalType();
Conversion<?> conversion = getData().getConversionFor(logicalType);
ensureAvailableMapBytes(in, l, eValue);
- Object map = newMap(old, (int) l);
+ Object map = newMap(old, initialCollectionCapacity(l));
if (l > 0) {
Review Comment:
`readMap()` now clamps the initial map capacity via
`initialCollectionCapacity(l)` to prevent huge preallocation when
`Decoder.remainingBytes()` is unknown (stream sources), but there isn’t a
targeted test that exercises the stream/unknown-remaining-bytes path for maps.
Without such a test, a future regression could reintroduce an OOM-on-stream
behavior even though the byte[]-backed map tests would still pass via the
bytes-available guard.
--
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]