Buggy code:
public class TestPayloadTermQuery extends LuceneTestCase { private IndexSearcher searcher ; private IndexReader reader ; private TestPayloadTermQuery . BoostingSimilarity similarity = new TestPayloadTermQuery . BoostingSimilarity ( ) ; private byte [ ] payloadField = new byte [ ] { 1 } ; private byte [ ] payloadMultiField1 = new byte [ ] { 2 } ; private byte [ ] payloadMultiField2 = new byte [ ] { 4 } ; protected Directory directory ; private class PayloadAnalyzer extends Analyzer { @ Override public TokenStream tokenStream ( String fieldName , Reader reader ) { } } private class PayloadFilter extends TokenFilter { String fieldName ; int numSeen = 0 ; PayloadAttribute payloadAtt ; public PayloadFilter ( TokenStream input , String fieldName ) { } @ Override public boolean incrementToken ( ) throws IOException { } } @ Override public void setUp ( ) throws Exception { } @ Override public void tearDown ( ) throws Exception { } public void test ( ) throws IOException { } public void testQuery ( ) { } public void testMultipleMatchesPerDoc ( ) throws Exception { } public void testIgnoreSpanScorer ( ) throws Exception { } public void testNoMatch ( ) throws Exception { } public void testNoPayload ( ) throws Exception { PayloadTermQuery q1 = new PayloadTermQuery ( new org . apache . lucene . index . Term ( PayloadHelper . NO_PAYLOAD_FIELD , "zero" ) , new MaxPayloadFunction ( ) ) ; PayloadTermQuery q2 = new PayloadTermQuery ( new org . apache . lucene . index . Term ( PayloadHelper . NO_PAYLOAD_FIELD , "foo" ) , new MaxPayloadFunction ( ) ) ; BooleanClause c1 = new BooleanClause ( q1 , Occur . MUST ) ; BooleanClause c2 = new BooleanClause ( q2 , Occur . MUST_NOT ) ; BooleanQuery query = new BooleanQuery ( ) ; query . add ( c1 ) ; query . add ( c2 ) ; TopDocs hits = searcher . search ( query , null , 100 ) ; assertTrue ( "hits<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>and<seq2seq4repair_space>it<seq2seq4repair_space>shouldn't<seq2seq4repair_space>be" , ( hits != null ) ) ; assertTrue ( ( ( ( "hits<seq2seq4repair_space>Size:<seq2seq4repair_space>" + ( hits . totalHits ) ) + "<seq2seq4repair_space>is<seq2seq4repair_space>not:<seq2seq4repair_space>" ) + 1 ) , ( ( hits . totalHits ) == 1 ) ) ; int [ ] results = new int [ 1 ] ; results [ 0 ] = 0 ; <START_BUG> CheckHits . checkHitCollector ( query , NO_PAYLOAD_FIELD , searcher , results ) ; <END_BUG> } static class BoostingSimilarity extends DefaultSimilarity { @ Override public float scorePayload ( int docId , String fieldName , int start , int end , byte [ ] payload , int offset , int length ) { } @ Override public float lengthNorm ( String fieldName , int numTerms ) { } @ Override public float queryNorm ( float sumOfSquaredWeights ) { } @ Override public float sloppyFreq ( int distance ) { } @ Override public float coord ( int overlap , int maxOverlap ) { } @ Override public float idf ( int docFreq , int numDocs ) { } @ Override public float tf ( float freq ) { } } static class FullSimilarity extends DefaultSimilarity { public float scorePayload ( int docId , String fieldName , byte [ ] payload , int offset , int length ) { } } }

Fix:
CheckHits . checkHitCollector ( random , query , NO_PAYLOAD_FIELD , searcher , results ) ;