Repository navigation
Fix CharArraySet equals/hashCode contract - #16261
mayya-sharipova wants to merge 4 commits into
Conversation
- Fix violation: inherited hashCode was identity-based (char[].hashCode()), breaking equals/hashCode contract - Override hashCode() with content-stable implementation using Arrays.hashCode() per element - Incorporate ignoreCase into both equals() and hashCode() so sets differing only in case mode are treated as unequal - Expose ignoreCase via isIgnoreCase() on CharArrayMap and CharArraySet Potential breakage: code comparing two CharArraySet instances with same words but different ignoreCase will now see them as unequal; code using CharArraySet as a map key will observe different bucketing.
There was a problem hiding this comment.
Pull request overview
This PR fixes CharArraySet’s equals/hashCode contract by making hashing content-stable for char[]-backed keys and by incorporating the ignoreCase flag into equality and hashing semantics. It also exposes the ignoreCase setting via isIgnoreCase() on both CharArrayMap and CharArraySet.
Changes:
- Add
isIgnoreCase()accessors toCharArrayMapandCharArraySet. - Override
CharArraySet.equals()andhashCode()to be content-based and to includeignoreCase. - Update/add tests around
equals/hashCode, and adjusttoString()expectations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lucene/core/src/java/org/apache/lucene/analysis/CharArraySet.java | Adds isIgnoreCase(), overrides equals/hashCode, and changes toString() output. |
| lucene/core/src/java/org/apache/lucene/analysis/CharArrayMap.java | Exposes the internal ignoreCase setting via isIgnoreCase(). |
| lucene/core/src/test/org/apache/lucene/analysis/TestCharArraySet.java | Updates toString() expectations and adds equals/hashCode regression tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
|
@mayya-sharipova @romseygeek are you planning to merge soon? If not, let's set the milestone to 12.0.0 |
Potential breakage: code comparing two CharArraySet instances with same words but different ignoreCase will now see them as unequal; code using CharArraySet as a map key will observe different bucketing.