Buggy code:
final class DocumentWriter { private Analyzer analyzer ; private Directory directory ; private Similarity similarity ; private FieldInfos fieldInfos ; private int maxFieldLength ; private int termIndexInterval = IndexWriter . DEFAULT_TERM_INDEX_INTERVAL ; private PrintStream infoStream ; DocumentWriter ( Directory directory , Analyzer analyzer , Similarity similarity , int maxFieldLength ) { } DocumentWriter ( Directory directory , Analyzer analyzer , IndexWriter writer ) { } final void addDocument ( String segment , Document doc ) throws IOException { } private final Hashtable postingTable = new Hashtable ( ) ; private int [ ] fieldLengths ; private int [ ] fieldPositions ; private int [ ] fieldOffsets ; private float [ ] fieldBoosts ; private final void invertDocument ( Document doc ) throws IOException { Enumeration fields = doc . fields ( ) ; while ( fields . hasMoreElements ( ) ) { Fieldable field = ( ( Fieldable ) ( fields . nextElement ( ) ) ) ; String fieldName = field . name ( ) ; int fieldNumber = fieldInfos . fieldNumber ( fieldName ) ; int length = fieldLengths [ fieldNumber ] ; int position = fieldPositions [ fieldNumber ] ; if ( length > 0 ) position += analyzer . getPositionIncrementGap ( fieldName ) ; int offset = fieldOffsets [ fieldNumber ] ; if ( field . isIndexed ( ) ) { if ( ! ( field . isTokenized ( ) ) ) { String stringValue = field . stringValue ( ) ; if ( field . isStoreOffsetWithTermVector ( ) ) addPosition ( fieldName , stringValue , ( position ++ ) , new TermVectorOffsetInfo ( offset , ( offset + ( stringValue . length ( ) ) ) ) ) ; else addPosition ( fieldName , stringValue , ( position ++ ) , null ) ; offset += stringValue . length ( ) ; length ++ ; } else { Reader reader ; if ( ( field . readerValue ( ) ) != null ) reader = field . readerValue ( ) ; else if ( ( field . stringValue ( ) ) != null ) reader = new StringReader ( field . stringValue ( ) ) ; else throw new IllegalArgumentException ( "field<seq2seq4repair_space>must<seq2seq4repair_space>have<seq2seq4repair_space>either<seq2seq4repair_space>String<seq2seq4repair_space>or<seq2seq4repair_space>Reader<seq2seq4repair_space>value" ) ; TokenStream stream = analyzer . tokenStream ( fieldName , reader ) ; try { Token lastToken = null ; for ( Token t = stream . next ( ) ; t != null ; t = stream . next ( ) ) { position += ( t . getPositionIncrement ( ) ) - 1 ; if ( field . isStoreOffsetWithTermVector ( ) ) addPosition ( fieldName , t . termText ( ) , ( position ++ ) , new TermVectorOffsetInfo ( ( offset + ( t . startOffset ( ) ) ) , ( offset + ( t . endOffset ( ) ) ) ) ) ; else addPosition ( fieldName , t . termText ( ) , ( position ++ ) , null ) ; lastToken = t ; <START_BUG> if ( ( ++ length ) > ( maxFieldLength ) ) { <END_BUG> if ( ( infoStream ) != null ) infoStream . println ( ( ( "maxFieldLength<seq2seq4repair_space>" + ( maxFieldLength ) ) + "<seq2seq4repair_space>reached,<seq2seq4repair_space>ignoring<seq2seq4repair_space>following<seq2seq4repair_space>tokens" ) ) ; break ; } } if ( lastToken != null ) offset += ( lastToken . endOffset ( ) ) + 1 ; } finally { stream . close ( ) ; } } fieldLengths [ fieldNumber ] = length ; fieldPositions [ fieldNumber ] = position ; fieldBoosts [ fieldNumber ] *= field . getBoost ( ) ; fieldOffsets [ fieldNumber ] = offset ; } } } private final Term termBuffer = new Term ( "" , "" ) ; private final void addPosition ( String field , String text , int position , TermVectorOffsetInfo offset ) { } private final Posting [ ] sortPostingTable ( ) { } private static final void quickSort ( Posting [ ] postings , int lo , int hi ) { } private final void writePostings ( Posting [ ] postings , String segment ) throws IOException { } private final void writeNorms ( String segment ) throws IOException { } void setInfoStream ( PrintStream infoStream ) { } }

Fix:
if ( ( ++ length ) >= ( maxFieldLength ) ) {