Skip to content

Fix NPE in RoaringDocIdSet.Iterator#intoBitSet#16252

Open
venkateshwaracholan wants to merge 1 commit into
apache:mainfrom
venkateshwaracholan:roaring_docidset_npe_fix
Open

Fix NPE in RoaringDocIdSet.Iterator#intoBitSet#16252
venkateshwaracholan wants to merge 1 commit into
apache:mainfrom
venkateshwaracholan:roaring_docidset_npe_fix

Conversation

@venkateshwaracholan

@venkateshwaracholan venkateshwaracholan commented Jun 13, 2026

Copy link
Copy Markdown

Description

RoaringDocIdSet.Iterator#intoBitSet can throw a NullPointerException when called after the iterator has been exhausted.

Once iteration reaches NO_MORE_DOCS, the underlying sub iterator is cleared. intoBitSet() does not currently handle that state and can still attempt to dereference the sub iterator.

Add a null check before accessing the sub iterator and treat exhausted iterators as a no-op.

Add a regression test that exhausts the iterator using both nextDoc() and advance() before calling intoBitSet().

The LRUQueryCache path reported in GITHUB#16250 has since been reworked on main, but the iterator bug itself is still present and the new test fails without this fix.

Fixes #16250

@github-actions github-actions Bot added this to the 11.0.0 milestone Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullPointerException in RoaringDocIdSet.Iterator.intoBitSet when the iterator is exhausted (this.sub == null)

1 participant