Buggy code:
public class PostingsHighlighter { private static final IndexReader EMPTY_INDEXREADER = new MultiReader ( ) ; public static final int DEFAULT_MAX_LENGTH = 10000 ; private final int maxLength ; private PassageFormatter defaultFormatter ; private PassageScorer defaultScorer ; public PostingsHighlighter ( ) { } public PostingsHighlighter ( int maxLength ) { } protected BreakIterator getBreakIterator ( String field ) { } protected PassageFormatter getFormatter ( String field ) { } protected PassageScorer getScorer ( String field ) { } public String [ ] highlight ( String field , Query query , IndexSearcher searcher , TopDocs topDocs ) throws IOException { } public String [ ] highlight ( String field , Query query , IndexSearcher searcher , TopDocs topDocs , int maxPassages ) throws IOException { } public Map < String , String [ ] > highlightFields ( String [ ] fields , Query query , IndexSearcher searcher , TopDocs topDocs ) throws IOException { } public Map < String , String [ ] > highlightFields ( String [ ] fields , Query query , IndexSearcher searcher , TopDocs topDocs , int [ ] maxPassages ) throws IOException { } public Map < String , String [ ] > highlightFields ( String [ ] fieldsIn , Query query , IndexSearcher searcher , int [ ] docidsIn , int [ ] maxPassagesIn ) throws IOException { } protected String [ ] [ ] loadFieldValues ( IndexSearcher searcher , String [ ] fields , int [ ] docids , int maxLength ) throws IOException { } private Map < Integer , String > highlightField ( String field , String [ ] contents , BreakIterator bi , BytesRef [ ] terms , int [ ] docids , List < AtomicReaderContext > leaves , int maxPassages ) throws IOException { } private Passage [ ] highlightDoc ( String field , BytesRef [ ] terms , int contentLength , BreakIterator bi , int doc , TermsEnum termsEnum , DocsAndPositionsEnum [ ] postings , int n ) throws IOException { } protected Passage [ ] getEmptyHighlight ( String fieldName , BreakIterator bi , int maxPassages ) { } private static class OffsetsEnum implements Comparable < PostingsHighlighter . OffsetsEnum > { DocsAndPositionsEnum dp ; int pos ; int id ; OffsetsEnum ( DocsAndPositionsEnum dp , int id ) throws IOException { } @ Override public int compareTo ( PostingsHighlighter . OffsetsEnum other ) { } } private static final DocsAndPositionsEnum EMPTY = new DocsAndPositionsEnum ( ) { @ Override public int nextPosition ( ) throws IOException { } @ Override public int startOffset ( ) throws IOException { } @ Override public int endOffset ( ) throws IOException { } @ Override public BytesRef getPayload ( ) throws IOException { } @ Override public int freq ( ) throws IOException { } @ Override public int docID ( ) { } @ Override public int nextDoc ( ) throws IOException { } @ Override public int advance ( int target ) throws IOException { } @ Override public long cost ( ) { } } ; private static Query rewrite ( Query original ) throws IOException { } private static class LimitedStoredFieldVisitor extends StoredFieldVisitor { private final String [ ] fields ; private final int maxLength ; private final StringBuilder [ ] builders ; private int currentField = - 1 ; public LimitedStoredFieldVisitor ( String [ ] fields , int maxLength ) { } @ Override public void stringField ( FieldInfo fieldInfo , String value ) throws IOException { assert ( currentField ) >= 0 ; StringBuilder builder = builders [ currentField ] ; <START_BUG> if ( ( builder . length ( ) ) > 0 ) { <END_BUG> builder . append ( '<seq2seq4repair_space>' ) ; } if ( ( ( builder . length ( ) ) + ( value . length ( ) ) ) > ( maxLength ) ) { builder . append ( value , 0 , ( ( maxLength ) - ( builder . length ( ) ) ) ) ; } else { builder . append ( value ) ; } } @ Override public Status needsField ( FieldInfo fieldInfo ) throws IOException { } String getValue ( int i ) { } void reset ( ) { } } }

Fix:
if ( ( ( builder . length ( ) ) > 0 ) && ( ( builder . length ( ) ) < ( maxLength ) ) ) {