Skip to content

Fix inverted fixed-size guard in FixedSizeSortedMap.putAll - #722

Merged
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:fixedsizesortedmap-putall-guard
Aug 8, 2026
Merged

Fix inverted fixed-size guard in FixedSizeSortedMap.putAll#722
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:fixedsizesortedmap-putall-guard

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

putAll inverted the isSubCollection check so it rejected legal value updates and let a new key grow the fixed-size map; negate it to match sibling FixedSizeMap.putAll, spotted while auditing the fixed-size decorators.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes FixedSizeSortedMap.putAll to correctly reject inserts of new keys into a fixed-size map while still allowing value updates for existing keys, aligning behavior with the fixed-size decorator contract and the sibling FixedSizeMap.putAll.

Changes:

  • Invert the CollectionUtils.isSubCollection guard in FixedSizeSortedMap.putAll so only new keys are rejected.
  • Add a focused JUnit test covering: existing-key updates, empty putAll no-op, and rejection of new keys without growing the map.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/main/java/org/apache/commons/collections4/map/FixedSizeSortedMap.java Corrects putAll guard condition to prevent adding new keys to a fixed-size sorted map.
src/test/java/org/apache/commons/collections4/map/FixedSizeSortedMapTest.java Adds regression test ensuring putAll allows updates but rejects new keys and preserves size.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@garydgregory garydgregory changed the title fix inverted fixed-size guard in FixedSizeSortedMap.putAll Fix inverted fixed-size guard in FixedSizeSortedMap.putAll Aug 8, 2026
@garydgregory
garydgregory merged commit 4390163 into apache:master Aug 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants