rootvector2 commented on PR #705:
URL: 
https://github.com/apache/commons-collections/pull/705#issuecomment-4935701566

   Went over the merged `AbstractMapMultiSet.add(E, int)` once more: negative 
`occurrences` throws, the per-element count saturates through the applied delta 
so `mut.value` can't wrap, and the exact total sits in the `long` `size` field 
and clamps in `size()`. The multiset regression test covers add saturation plus 
removal while the true size is still above `Integer.MAX_VALUE`, so I don't see 
anything left in that path.
   
   On the wider int/long pass: the same summation overflow exists in 
`CompositeCollection.size()`, `CompositeSet.size()` and `CompositeMap.size()`, 
which sum member sizes into an int. `CompositeMap`'s javadoc even promises 
`Integer.MAX_VALUE` but the sum wraps negative, and it's cheap to hit now by 
compositing two bags at max size. `AbstractMultiValuedMap.size()` and 
`AbstractMultiSet.size()` (for subclasses that don't override it) accumulate 
the same way. I'll put together a follow-up PR for those.
   
   Thanks for merging this one.


-- 
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]

Reply via email to