You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "venkateshwaracholan (via GitHub)" <gi...@apache.org> on 2026/06/13 04:24:36 UTC

[PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

venkateshwaracholan opened a new pull request, #16252:
URL: https://github.com/apache/lucene/pull/16252

   ### 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.
   
   
   <!--
   If this is your first contribution to Lucene, please make sure you have reviewed the contribution guide.
   https://github.com/apache/lucene/blob/main/CONTRIBUTING.md
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429475584


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
   You need to still point this PR to main, we will take care of the backports.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on PR #16252:
URL: https://github.com/apache/lucene/pull/16252#issuecomment-4732968264

   Thanks @venkateshwaracholan 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429562740


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
   At the end of this section: https://github.com/apache/lucene/blob/7787b70ab5d89985d4a3c33e023bd9fcd69c4916/lucene/CHANGES.txt#L539



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429475584


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
   You need to still point this PR to main



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iprithv (via GitHub)" <gi...@apache.org>.
iprithv commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3422785798


##########
lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java:
##########
@@ -454,6 +454,9 @@ private int firstDocFromNextBlock() throws IOException {
     @Override
     public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
       for (; ; ) {
+        if (sub == null) {

Review Comment:
   intoBitSet overrides in the codebase guard exhaustion by checking doc rather than sub..since it's Integer.MAX_VALUE. you could do the same here!
   
   ```suggestion
           if (doc == NO_MORE_DOCS) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3428900502


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
   I think we should be targeting 10.5, not 11, could you move the entry to that version?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429469265


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
    branch_10x will be cut on thee next few days to create branch_10_5, there is a release coming soon.
   
   You can see a bit below a section with the header `Lucene 10.5.0`, you should add the entry there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429469265


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
    branch_10x will be cut on the next few days to create branch_10_5, there is a release coming soon.
   
   You can see a bit below a section with the header `Lucene 10.5.0`, you should add the entry there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "venkateshwaracholan (via GitHub)" <gi...@apache.org>.
venkateshwaracholan commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3425237008


##########
lucene/core/src/java/org/apache/lucene/util/RoaringDocIdSet.java:
##########
@@ -454,6 +454,9 @@ private int firstDocFromNextBlock() throws IOException {
     @Override
     public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws IOException {
       for (; ; ) {
+        if (sub == null) {

Review Comment:
   @iprithv Thanks for the review. Using `doc == NO_MORE_DOCS` here is cleaner and more consistent with the other `intoBitSet()` implementations. I've updated the check and pushed the change.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "venkateshwaracholan (via GitHub)" <gi...@apache.org>.
venkateshwaracholan commented on code in PR #16252:
URL: https://github.com/apache/lucene/pull/16252#discussion_r3429431767


##########
lucene/CHANGES.txt:
##########
@@ -158,6 +158,9 @@ Optimizations
 
 Bug Fixes
 ---------------------
+* GITHUB#16250: Fix NullPointerException in RoaringDocIdSet#intoBitSet when the iterator is already

Review Comment:
   Thanks for the review.
   
   I don't currently see a 10.5 maintenance branch in the repository (I only see branch_10_4, branch_10x)
   Could you clarify the preferred location for the CHANGES entry?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Re: [PR] Fix NPE in RoaringDocIdSet.Iterator#intoBitSet [lucene]

Posted by "iverase (via GitHub)" <gi...@apache.org>.
iverase merged PR #16252:
URL: https://github.com/apache/lucene/pull/16252


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org