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" } ; 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 { } private void tstNextSpans ( Spans spans , int doc , int start , int end ) throws Exception { } public void testSpanOrEmpty ( ) throws Exception { } public void testSpanOrSingle ( ) throws Exception { } public void testSpanOrMovesForward ( ) throws Exception { } public void testSpanOrDouble ( ) throws Exception { } public void testSpanOrDoubleSkip ( ) throws Exception { } public void testSpanOrUnused ( ) throws Exception { } public void testSpanOrTripleSameDoc ( ) throws Exception { } public void testSpanScorerZeroSloppyFreq ( ) throws Exception { boolean ordered = true ; int slop = 1 ; ReaderContext topReaderContext = searcher . getTopReaderContext ( ) ; AtomicReaderContext [ ] leaves = ReaderUtil . leaves ( topReaderContext ) ; int subIndex = ReaderUtil . subIndex ( 11 , leaves ) ; for ( int i = 0 ; i < ( leaves . length ) ; i ++ ) { final SimilarityProvider sim = new DefaultSimilarityProvider ( ) { public Similarity get ( String field ) { return new DefaultSimilarity ( ) { @ Override public float sloppyFreq ( int distance ) { return 0.0F ; } } ; } } ; final SimilarityProvider oldSim = searcher . getSimilarityProvider ( ) ; Scorer spanScorer ; try { searcher . setSimilarityProvider ( sim ) ; SpanNearQuery snq = new SpanNearQuery ( new SpanQuery [ ] { makeSpanTermQuery ( "t1" ) , makeSpanTermQuery ( "t2" ) } , slop , ordered ) ; <START_BUG> spanScorer = snq . weight ( searcher ) . scorer ( leaves [ i ] , ScorerContext . def ( ) ) ; <END_BUG> } finally { searcher . setSimilarityProvider ( 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 ( ) ) + ( leaves [ i ] . 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 { assertTrue ( "no<seq2seq4repair_space>second<seq2seq4repair_space>doc" , ( ( spanScorer . nextDoc ( ) ) == ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ; } } } 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 { } }

Fix:
spanScorer = searcher . createNormalizedWeight ( snq ) . scorer ( leaves [ i ] , ScorerContext . def ( ) ) ;