apache / apache/lucene

OpenBitSet hashCode and equals incongruent [LUCENE-5423]

Open
#6,486 1 comment 0 reactions 0 assignees View on GitHub
affects-version:4.6.1 legacy-jira-priority:Major module:core/other type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

In org.apache.lucene.util.OpenBitSet the hashCode method might return different hash codes for equal bitsets.
This happens when there are bits set in words right of wlen. This might happen through a getAndSet call (the documentation states that getAndSet may only be called on positions that are smaller than the size - which is the length of the array not wlen - this might be another issue).

---
Migrated from [LUCENE-5423](https://issues.apache.org/jira/browse/LUCENE-5423) by Jakob Zwiener

Contributor guide

Open the contributing guide

Research direction

Start with org.apache.lucene.util.OpenBitSet, reading its hashCode and equals implementations alongside getAndSet and the wlen-related behavior described in the report. Reproduce a case with bits set beyond wlen, then verify that equal bitsets produce equal hash codes and that the relevant behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.