Skip to content

Remove stale keys in OrderedProperties compute and merge#702

Merged
garydgregory merged 1 commit into
apache:masterfrom
rootvector2:ordered-properties-stale-key
Jul 4, 2026
Merged

Remove stale keys in OrderedProperties compute and merge#702
garydgregory merged 1 commit into
apache:masterfrom
rootvector2:ordered-properties-stale-key

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

OrderedProperties keeps a parallel orderedKeys set that backs keys(), keySet(), entrySet() and toString(), but compute() and merge() only ever add to it. both operations remove the mapping from the backing Hashtable when the remapping function returns null, so after compute(key, (k, v) -> null) on a present key the mapping is gone yet the key still shows up in keySet(), size() disagrees with the key view, and toString() throws NullPointerException on the stale key's null value.

remove the key from orderedKeys when the result is null. a Hashtable never stores null values, so a null result means the mapping was removed, which is what the existing remove() overrides already do. found while auditing the ordered-view bookkeeping against the Properties contract; SortedProperties derives its keys live from super.keySet() and needs no change.

@garydgregory garydgregory changed the title remove stale keys in OrderedProperties compute and merge Remove stale keys in OrderedProperties compute and merge Jul 4, 2026
@garydgregory garydgregory merged commit 751a986 into apache:master Jul 4, 2026
10 checks passed
garydgregory added a commit that referenced this pull request Jul 4, 2026
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