Buggy code:
private void msg ( String msg ) { } public CheckIndex . Status checkIndex ( ) throws IOException { } public CheckIndex . Status checkIndex ( List < String > onlySegments ) throws IOException { } public CheckIndex . Status checkIndex ( List < String > onlySegments , CodecProvider codecs ) throws IOException { } private CheckIndex . Status . FieldNormStatus testFieldNorms ( Collection < String > fieldNames , SegmentReader reader ) { } private CheckIndex . Status . TermIndexStatus testTermIndex ( SegmentReader reader ) { final CheckIndex . Status . TermIndexStatus status = new CheckIndex . Status . TermIndexStatus ( ) ; final int maxDoc = reader . maxDoc ( ) ; final Bits delDocs = reader . getDeletedDocs ( ) ; try { if ( ( infoStream ) != null ) { infoStream . print ( "<seq2seq4repair_space>test:<seq2seq4repair_space>terms,<seq2seq4repair_space>freq,<seq2seq4repair_space>prox..." ) ; } final Fields fields = reader . fields ( ) ; if ( fields == null ) { msg ( "OK<seq2seq4repair_space>[no<seq2seq4repair_space>fields//terms]" ) ; return status ; } final FieldsEnum fieldsEnum = fields . iterator ( ) ; while ( true ) { final String field = fieldsEnum . next ( ) ; if ( field == null ) { break ; } final TermsEnum terms = fieldsEnum . terms ( ) ; DocsEnum docs = null ; DocsAndPositionsEnum postings = null ; boolean hasOrd = true ; final long termCountStart = status . termCount ; while ( true ) { final BytesRef term = terms . next ( ) ; if ( term == null ) { break ; } final int docFreq = terms . docFreq ( ) ; status . totFreq += docFreq ; docs = terms . docs ( delDocs , docs ) ; postings = terms . docsAndPositions ( delDocs , postings ) ; if ( hasOrd ) { long ord = - 1 ; try { ord = terms . ord ( ) ; } catch ( UnsupportedOperationException uoe ) { hasOrd = false ; } if ( hasOrd ) { final long ordExpected = ( status . termCount ) - termCountStart ; if ( ord != ordExpected ) { throw new RuntimeException ( ( ( ( "ord<seq2seq4repair_space>mismatch:<seq2seq4repair_space>TermsEnum<seq2seq4repair_space>has<seq2seq4repair_space>ord=" + ord ) + "<seq2seq4repair_space>vs<seq2seq4repair_space>actual=" ) + ordExpected ) ) ; } } } ( status . termCount ) ++ ; final DocsEnum docs2 ; if ( postings != null ) { docs2 = postings ; } else { docs2 = docs ; } int lastDoc = - 1 ; while ( true ) { final int doc = docs2 . nextDoc ( ) ; if ( doc == ( DocsEnum . NO_MORE_DOCS ) ) { break ; } final int freq = docs2 . freq ( ) ; status . totPos += freq ; if ( doc <= lastDoc ) { throw new RuntimeException ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + ":<seq2seq4repair_space>doc<seq2seq4repair_space>" ) + doc ) + "<seq2seq4repair_space><=<seq2seq4repair_space>lastDoc<seq2seq4repair_space>" ) + lastDoc ) ) ; } if ( doc >= maxDoc ) { throw new RuntimeException ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + ":<seq2seq4repair_space>doc<seq2seq4repair_space>" ) + doc ) + "<seq2seq4repair_space>>=<seq2seq4repair_space>maxDoc<seq2seq4repair_space>" ) + maxDoc ) ) ; } lastDoc = doc ; if ( freq <= 0 ) { throw new RuntimeException ( ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + ":<seq2seq4repair_space>doc<seq2seq4repair_space>" ) + doc ) + ":<seq2seq4repair_space>freq<seq2seq4repair_space>" ) + freq ) + "<seq2seq4repair_space>is<seq2seq4repair_space>out<seq2seq4repair_space>of<seq2seq4repair_space>bounds" ) ) ; } int lastPos = - 1 ; if ( postings != null ) { for ( int j = 0 ; j < freq ; j ++ ) { final int pos = postings . nextPosition ( ) ; if ( pos < ( - 1 ) ) { throw new RuntimeException ( ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + ":<seq2seq4repair_space>doc<seq2seq4repair_space>" ) + doc ) + ":<seq2seq4repair_space>pos<seq2seq4repair_space>" ) + pos ) + "<seq2seq4repair_space>is<seq2seq4repair_space>out<seq2seq4repair_space>of<seq2seq4repair_space>bounds" ) ) ; } if ( pos < lastPos ) { throw new RuntimeException ( ( ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + ":<seq2seq4repair_space>doc<seq2seq4repair_space>" ) + doc ) + ":<seq2seq4repair_space>pos<seq2seq4repair_space>" ) + pos ) + "<seq2seq4repair_space><<seq2seq4repair_space>lastPos<seq2seq4repair_space>" ) + lastPos ) ) ; } lastPos = pos ; <START_BUG> if ( ( postings . getPayloadLength ( ) ) != 0 ) { <END_BUG> postings . getPayload ( ) ; } } } } if ( reader . hasDeletions ( ) ) { final DocsEnum docsNoDel = terms . docs ( null , docs ) ; int count = 0 ; while ( ( docsNoDel . nextDoc ( ) ) != ( DocsEnum . NO_MORE_DOCS ) ) { count ++ ; } if ( count != docFreq ) { throw new RuntimeException ( ( ( ( ( ( "term<seq2seq4repair_space>" + term ) + "<seq2seq4repair_space>docFreq=" ) + docFreq ) + "<seq2seq4repair_space>!=<seq2seq4repair_space>tot<seq2seq4repair_space>docs<seq2seq4repair_space>w//o<seq2seq4repair_space>deletions<seq2seq4repair_space>" ) + count ) ) ; } } } } msg ( ( ( ( ( ( ( "OK<seq2seq4repair_space>[" + ( status . termCount ) ) + "<seq2seq4repair_space>terms;<seq2seq4repair_space>" ) + ( status . totFreq ) ) + "<seq2seq4repair_space>terms//docs<seq2seq4repair_space>pairs;<seq2seq4repair_space>" ) + ( status . totPos ) ) + "<seq2seq4repair_space>tokens]" ) ) ; } catch ( Throwable e ) { msg ( ( ( "ERROR<seq2seq4repair_space>[" + ( String . valueOf ( e . getMessage ( ) ) ) ) + "]" ) ) ; status . error = e ; if ( ( infoStream ) != null ) { e . printStackTrace ( infoStream ) ; } } return status ; } private CheckIndex . Status . StoredFieldStatus testStoredFields ( SegmentInfo info , SegmentReader reader , NumberFormat format ) { } private CheckIndex . Status . TermVectorStatus testTermVectors ( SegmentInfo info , SegmentReader reader , NumberFormat format ) { } public void fixIndex ( CheckIndex . Status result ) throws IOException { } private static boolean assertsOn ; private static boolean testAsserts ( ) { } private static boolean assertsOn ( ) { } public static void main ( String [ ] args ) throws IOException , InterruptedException { } }

Fix:
if ( postings . hasPayload ( ) ) {