Buggy code:
public class TestSpans extends LuceneTestCase { private IndexSearcher searcher ; private IndexReader reader ; private Directory directory ; public static final String field = "field" ; @ Override public void setUp ( ) throws Exception { } @ Override public void tearDown ( ) throws Exception { } private String [ ] docFields = new String [ ] { "w1<seq2seq4repair_space>w2<seq2seq4repair_space>w3<seq2seq4repair_space>w4<seq2seq4repair_space>w5" , "w1<seq2seq4repair_space>w3<seq2seq4repair_space>w2<seq2seq4repair_space>w3" , "w1<seq2seq4repair_space>xx<seq2seq4repair_space>w2<seq2seq4repair_space>yy<seq2seq4repair_space>w3" , "w1<seq2seq4repair_space>w3<seq2seq4repair_space>xx<seq2seq4repair_space>w2<seq2seq4repair_space>yy<seq2seq4repair_space>w3" , "u2<seq2seq4repair_space>u2<seq2seq4repair_space>u1" , "u2<seq2seq4repair_space>xx<seq2seq4repair_space>u2<seq2seq4repair_space>u1" , "u2<seq2seq4repair_space>u2<seq2seq4repair_space>xx<seq2seq4repair_space>u1" , "u2<seq2seq4repair_space>xx<seq2seq4repair_space>u2<seq2seq4repair_space>yy<seq2seq4repair_space>u1" , "u2<seq2seq4repair_space>xx<seq2seq4repair_space>u1<seq2seq4repair_space>u2" , "u2<seq2seq4repair_space>u1<seq2seq4repair_space>xx<seq2seq4repair_space>u2" , "u1<seq2seq4repair_space>u2<seq2seq4repair_space>xx<seq2seq4repair_space>u2" , "t1<seq2seq4repair_space>t2<seq2seq4repair_space>t1<seq2seq4repair_space>t3<seq2seq4repair_space>t2<seq2seq4repair_space>t3" , "s2<seq2seq4repair_space>s1<seq2seq4repair_space>s1<seq2seq4repair_space>xx<seq2seq4repair_space>xx<seq2seq4repair_space>s2<seq2seq4repair_space>xx<seq2seq4repair_space>s2<seq2seq4repair_space>xx<seq2seq4repair_space>s1<seq2seq4repair_space>xx<seq2seq4repair_space>xx<seq2seq4repair_space>xx<seq2seq4repair_space>xx<seq2seq4repair_space>xx<seq2seq4repair_space>s2<seq2seq4repair_space>xx" } ; public SpanTermQuery makeSpanTermQuery ( String text ) { } private void checkHits ( Query query , int [ ] results ) throws IOException { } private void orderedSlopTest3SQ ( SpanQuery q1 , SpanQuery q2 , SpanQuery q3 , int slop , int [ ] expectedDocs ) throws IOException { } public void orderedSlopTest3 ( int slop , int [ ] expectedDocs ) throws IOException { } public void orderedSlopTest3Equal ( int slop , int [ ] expectedDocs ) throws IOException { } public void orderedSlopTest1Equal ( int slop , int [ ] expectedDocs ) throws IOException { } public void testSpanNearOrdered01 ( ) throws Exception { } public void testSpanNearOrdered02 ( ) throws Exception { } public void testSpanNearOrdered03 ( ) throws Exception { } public void testSpanNearOrdered04 ( ) throws Exception { } public void testSpanNearOrdered05 ( ) throws Exception { } public void testSpanNearOrderedEqual01 ( ) throws Exception { } public void testSpanNearOrderedEqual02 ( ) throws Exception { } public void testSpanNearOrderedEqual03 ( ) throws Exception { } public void testSpanNearOrderedEqual04 ( ) throws Exception { } public void testSpanNearOrderedEqual11 ( ) throws Exception { } public void testSpanNearOrderedEqual12 ( ) throws Exception { } public void testSpanNearOrderedEqual13 ( ) throws Exception { } public void testSpanNearOrderedEqual14 ( ) throws Exception { } public void testSpanNearOrderedEqual15 ( ) throws Exception { } public void testSpanNearOrderedOverlap ( ) throws Exception { } public void testSpanNearUnOrdered ( ) throws Exception { } private Spans orSpans ( String [ ] terms ) throws Exception { } public static void tstNextSpans ( Spans spans , int doc , int start , int end ) throws IOException { } public static void tstEndSpans ( Spans spans ) throws Exception { } public void testSpanOrEmpty ( ) throws Exception { } public void testSpanOrSingle ( ) throws Exception { } public void testSpanOrDouble ( ) throws Exception { } public void testSpanOrDoubleAdvance ( ) throws Exception { } public void testSpanOrUnused ( ) throws Exception { } public void testSpanOrTripleSameDoc ( ) throws Exception { } public void testSpanScorerZeroSloppyFreq ( ) throws Exception { boolean ordered = true ; int slop = 1 ; IndexReaderContext topReaderContext = searcher . getTopReaderContext ( ) ; List < LeafReaderContext > leaves = topReaderContext . leaves ( ) ; int subIndex = ReaderUtil . subIndex ( 11 , leaves ) ; for ( int i = 0 , c = leaves . size ( ) ; i < c ; i ++ ) { final LeafReaderContext ctx = leaves . get ( i ) ; final Similarity sim = new DefaultSimilarity ( ) { @ Override public float sloppyFreq ( int distance ) { return 0.0F ; } } ; final Similarity oldSim = searcher . getSimilarity ( ) ; Scorer spanScorer ; try { searcher . setSimilarity ( sim ) ; SpanNearQuery snq = new SpanNearQuery ( new SpanQuery [ ] { makeSpanTermQuery ( "t1" ) , makeSpanTermQuery ( "t2" ) } , slop , ordered ) ; spanScorer = searcher . createNormalizedWeight ( snq , true ) . scorer ( ctx , ctx . reader ( ) . getLiveDocs ( ) ) ; } finally { searcher . setSimilarity ( oldSim ) ; } if ( i == subIndex ) { assertTrue ( "first<seq2seq4repair_space>doc" , ( ( spanScorer . nextDoc ( ) ) != ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ; assertEquals ( "first<seq2seq4repair_space>doc<seq2seq4repair_space>number" , ( ( spanScorer . docID ( ) ) + ( ctx . docBase ) ) , 11 ) ; float score = spanScorer . score ( ) ; assertTrue ( ( "first<seq2seq4repair_space>doc<seq2seq4repair_space>score<seq2seq4repair_space>should<seq2seq4repair_space>be<seq2seq4repair_space>zero,<seq2seq4repair_space>" + score ) , ( score == 0.0F ) ) ; } else { <START_BUG> assertTrue ( "no<seq2seq4repair_space>second<seq2seq4repair_space>doc" , ( ( spanScorer . nextDoc ( ) ) == ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ; <END_BUG> } } } private void addDoc ( IndexWriter writer , String id , String text ) throws IOException { } private int hitCount ( IndexSearcher searcher , String word ) throws Throwable { } private SpanQuery createSpan ( String value ) { } private SpanQuery createSpan ( int slop , boolean ordered , SpanQuery [ ] clauses ) { } private SpanQuery createSpan ( int slop , boolean ordered , String term1 , String term2 ) { } public void testNPESpanQuery ( ) throws Throwable { } public void testSpanNots ( ) throws Throwable { } private int spanCount ( String include , String exclude , int pre , int post ) throws IOException { } }

Fix:
assertTrue ( "no<seq2seq4repair_space>second<seq2seq4repair_space>doc" , ( ( spanScorer == null ) || ( ( spanScorer . nextDoc ( ) ) == ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ) ;