rootvector2 commented on PR #705: URL: https://github.com/apache/commons-collections/pull/705#issuecomment-4934382255
`remove()` already rejects negatives on both sides: `AbstractMapBag.remove(Object, int)` returns false for `nCopies <= 0` and `AbstractMapMultiSet.remove(Object, int)` throws `IllegalArgumentException`, so counts cannot grow through it. The copilot comments are right about the stored clamp though: once `size` saturated, removals dropped `size()` below `Integer.MAX_VALUE` while the true cardinality was still above it. Reworked: `size` is now a `long` kept exact and clamped on return in `size()`. Per-element counts still saturate at `Integer.MAX_VALUE` since they are stored as `int`, and `size` only accrues the applied delta so it always equals the sum of counts. Both tests now cover removal while the true size is still above `Integer.MAX_VALUE`. Full suite, checkstyle, pmd and japicmp are green. -- 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]
