Skip to content

Fix Flat3Map entrySet remove ignoring the entry value#714

Merged
garydgregory merged 3 commits into
apache:masterfrom
rootvector2:flat3map-entryset-remove-value
Jul 17, 2026
Merged

Fix Flat3Map entrySet remove ignoring the entry value#714
garydgregory merged 3 commits into
apache:masterfrom
rootvector2:flat3map-entryset-remove-value

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

noticed Flat3Map.EntrySet.remove diverges from AbstractHashedMap: it removes on a key match alone, so entrySet().remove(entry) drops a mapping even when the entry value differs; guard with contains(obj) so only a full key-and-value match removes.

  • 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.

EntrySet.remove deleted on a key match alone; guard with contains(obj) so only a full key-and-value match removes, matching AbstractHashedMap.
@garydgregory garydgregory changed the title fix Flat3Map entrySet remove ignoring the entry value Fix Flat3Map entrySet remove ignoring the entry value Jul 17, 2026
@garydgregory

garydgregory commented Jul 17, 2026

Copy link
Copy Markdown
Member

Good one @rootvector2 , will merge 🚀 . We have many of these types of types which may suffer from the same issue. Would you please check other Maps? TY! In the future, don't edit changes.xml.

@garydgregory
garydgregory merged commit 14375bd into apache:master Jul 17, 2026
10 checks passed
@rootvector2

Copy link
Copy Markdown
Contributor Author

went through the other EntrySet.remove implementations: AbstractHashedMap and AbstractPatriciaTrie guard with contains(obj), TreeBidiMap (both views), AbstractDualBidiMap, PassiveExpiringMap and ListOrderedMap all check the value, StaticBucketMap compares entries via Node.equals (key and value), and ConcurrentReferenceHashMap delegates to remove(key, value). Flat3Map was the only one removing on key alone, so nothing else needs fixing. noted on changes.xml, will leave it out going forward. thanks for merging.

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.

2 participants