diff --git a/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java b/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java index 1da99d5fe42..5a8bad99e24 100644 --- a/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java +++ b/lucene/core/src/test/org/apache/lucene/search/spans/TestSpans.java @@ -376,8 +376,8 @@ public class TestSpans extends LuceneTestCase { assertEquals("first doc number", spanScorer.docID() + ctx.docBase, 11); float score = spanScorer.score(); assertTrue("first doc score should be zero, " + score, score == 0.0f); - } else { - assertTrue("no second doc", spanScorer.nextDoc() == DocIdSetIterator.NO_MORE_DOCS); + } else { + assertTrue("no second doc", spanScorer == null || spanScorer.nextDoc() == DocIdSetIterator.NO_MORE_DOCS); } } }