Buggy code:
public void analyse ( TalismaneConfig config ) { try { if ( config . needsSentenceDetector ( ) ) { if ( ( config . getSentenceDetector ( ) ) == null ) { throw new TalismaneException ( "Sentence<seq2seq4repair_space>detector<seq2seq4repair_space>not<seq2seq4repair_space>provided." ) ; } } if ( config . needsTokeniser ( ) ) { if ( ( config . getTokeniser ( ) ) == null ) { throw new TalismaneException ( "Tokeniser<seq2seq4repair_space>not<seq2seq4repair_space>provided." ) ; } } if ( config . needsPosTagger ( ) ) { if ( ( config . getPosTagger ( ) ) == null ) { throw new TalismaneException ( "Pos-tagger<seq2seq4repair_space>not<seq2seq4repair_space>provided." ) ; } } if ( config . needsParser ( ) ) { if ( ( config . getParser ( ) ) == null ) { throw new TalismaneException ( "Parser<seq2seq4repair_space>not<seq2seq4repair_space>provided." ) ; } } if ( config . getEndModule ( ) . equals ( SentenceDetector ) ) { if ( ( this . getSentenceProcessor ( ) ) == null ) { throw new TalismaneException ( "No<seq2seq4repair_space>sentence<seq2seq4repair_space>processor<seq2seq4repair_space>provided<seq2seq4repair_space>with<seq2seq4repair_space>sentence<seq2seq4repair_space>detector<seq2seq4repair_space>end<seq2seq4repair_space>module,<seq2seq4repair_space>cannot<seq2seq4repair_space>generate<seq2seq4repair_space>output." ) ; } } if ( config . getEndModule ( ) . equals ( Tokeniser ) ) { if ( ( this . getTokenSequenceProcessor ( ) ) == null ) { throw new TalismaneException ( "No<seq2seq4repair_space>token<seq2seq4repair_space>sequence<seq2seq4repair_space>processor<seq2seq4repair_space>provided<seq2seq4repair_space>with<seq2seq4repair_space>tokeniser<seq2seq4repair_space>end<seq2seq4repair_space>module,<seq2seq4repair_space>cannot<seq2seq4repair_space>generate<seq2seq4repair_space>output." ) ; } } if ( config . getEndModule ( ) . equals ( PosTagger ) ) { if ( ( this . getPosTagSequenceProcessor ( ) ) == null ) { throw new TalismaneException ( "No<seq2seq4repair_space>postag<seq2seq4repair_space>sequence<seq2seq4repair_space>processor<seq2seq4repair_space>provided<seq2seq4repair_space>with<seq2seq4repair_space>pos-tagger<seq2seq4repair_space>end<seq2seq4repair_space>module,<seq2seq4repair_space>cannot<seq2seq4repair_space>generate<seq2seq4repair_space>output." ) ; } } if ( config . getEndModule ( ) . equals ( Parser ) ) { if ( ( this . getParseConfigurationProcessor ( ) ) == null ) { throw new TalismaneException ( "No<seq2seq4repair_space>parse<seq2seq4repair_space>configuration<seq2seq4repair_space>processor<seq2seq4repair_space>provided<seq2seq4repair_space>with<seq2seq4repair_space>parser<seq2seq4repair_space>end<seq2seq4repair_space>module,<seq2seq4repair_space>cannot<seq2seq4repair_space>generate<seq2seq4repair_space>output." ) ; } } LinkedList < String > textSegments = new LinkedList < String > ( ) ; LinkedList < Sentence > sentences = new LinkedList < Sentence > ( ) ; TokenSequence tokenSequence = null ; PosTagSequence posTagSequence = null ; RollingSentenceProcessor rollingSentenceProcessor = this . getFilterService ( ) . getRollingSentenceProcessor ( config . getFileName ( ) , config . isProcessByDefault ( ) ) ; if ( ( this . getReader ( ) ) instanceof CurrentFileProvider ) { ( ( CurrentFileProvider ) ( this . getReader ( ) ) ) . addCurrentFileObserver ( rollingSentenceProcessor ) ; } Sentence leftover = null ; if ( ( config . getStartModule ( ) . equals ( SentenceDetector ) ) || ( config . getStartModule ( ) . equals ( Tokeniser ) ) ) { textSegments . addLast ( "" ) ; textSegments . addLast ( "" ) ; } StringBuilder stringBuilder = new StringBuilder ( ) ; boolean finished = false ; int sentenceCount = 0 ; String prevProcessedText = "" ; String processedText = "" ; String nextProcessedText = "" ; SentenceHolder prevSentenceHolder = null ; int endBlockCharacterCount = 0 ; while ( ! finished ) { if ( ( config . getStartModule ( ) . equals ( SentenceDetector ) ) || ( config . getStartModule ( ) . equals ( Tokeniser ) ) ) { char c ; int r = - 1 ; try { r = this . getReader ( ) . read ( ) ; } catch ( IOException e ) { LogUtils . logError ( TalismaneImpl . LOG , e ) ; } if ( r == ( - 1 ) ) { finished = true ; c = '\n' ; } else { c = ( ( char ) ( r ) ) ; } if ( c == ( config . getEndBlockCharacter ( ) ) ) { endBlockCharacterCount ++ ; if ( endBlockCharacterCount == 3 ) { TalismaneImpl . LOG . info ( "Three<seq2seq4repair_space>consecutive<seq2seq4repair_space>end-block<seq2seq4repair_space>characters.<seq2seq4repair_space>Exiting." ) ; finished = true ; } } else { endBlockCharacterCount = 0 ; } <START_BUG> if ( ( finished || ( ( Character . isWhitespace ( c ) ) && ( ( stringBuilder . length ( ) ) > ( config . getBlockSize ( ) ) ) ) ) || ( c == ( config . getEndBlockCharacter ( ) ) ) ) { <END_BUG> if ( c == ( config . getEndBlockCharacter ( ) ) ) stringBuilder . append ( c ) ; if ( ( stringBuilder . length ( ) ) > 0 ) { String textSegment = stringBuilder . toString ( ) ; stringBuilder = new StringBuilder ( ) ; textSegments . add ( textSegment ) ; } if ( c == ( config . getEndBlockCharacter ( ) ) ) { textSegments . addLast ( "" ) ; } } if ( finished ) { if ( ( stringBuilder . length ( ) ) > 0 ) { textSegments . addLast ( stringBuilder . toString ( ) ) ; stringBuilder = new StringBuilder ( ) ; } textSegments . addLast ( "" ) ; textSegments . addLast ( "" ) ; textSegments . addLast ( "" ) ; } if ( c != ( config . getEndBlockCharacter ( ) ) ) stringBuilder . append ( c ) ; while ( ( textSegments . size ( ) ) >= 3 ) { String prevText = textSegments . removeFirst ( ) ; String text = textSegments . removeFirst ( ) ; String nextText = textSegments . removeFirst ( ) ; if ( TalismaneImpl . LOG . isTraceEnabled ( ) ) { TalismaneImpl . LOG . trace ( ( "prevText:<seq2seq4repair_space>" + prevText ) ) ; TalismaneImpl . LOG . trace ( ( "text:<seq2seq4repair_space>" + text ) ) ; TalismaneImpl . LOG . trace ( ( "nextText:<seq2seq4repair_space>" + nextText ) ) ; } Set < TextMarker > textMarkers = new TreeSet < TextMarker > ( ) ; for ( TextMarkerFilter textMarkerFilter : config . getTextMarkerFilters ( ) ) { Set < TextMarker > result = textMarkerFilter . apply ( prevText , text , nextText ) ; textMarkers . addAll ( result ) ; } textSegments . addFirst ( nextText ) ; textSegments . addFirst ( text ) ; SentenceHolder sentenceHolder = rollingSentenceProcessor . addNextSegment ( text , textMarkers ) ; prevProcessedText = processedText ;

Fix:
if ( ( finished || ( ( ( ( Character . isWhitespace ( c ) ) && ( c != '\r' ) ) && ( c != '\n' ) ) && ( ( stringBuilder . length ( ) ) > ( config . getBlockSize ( ) ) ) ) ) || ( c == ( config . getEndBlockCharacter ( ) ) ) ) {