Buggy code:
public void add ( BytesRef input , T output ) throws IOException { } public void add ( char [ ] s , int offset , int length , T output ) throws IOException { } public void add ( CharSequence s , T output ) throws IOException { } public void add ( IntsRef input , T output ) throws IOException { assert ( ( lastInput . length ) == 0 ) || ( ( input . compareTo ( lastInput ) ) >= 0 ) : ( ( "inputs<seq2seq4repair_space>are<seq2seq4repair_space>added<seq2seq4repair_space>out<seq2seq4repair_space>of<seq2seq4repair_space>order<seq2seq4repair_space>lastInput=" + ( lastInput ) ) + "<seq2seq4repair_space>vs<seq2seq4repair_space>input=" ) + input ; assert validOutput ( output ) ; if ( ( input . length ) == 0 ) { ( frontier [ 0 ] . inputCount ) ++ ; frontier [ 0 ] . isFinal = true ; fst . setEmptyOutput ( output ) ; return ; } int pos1 = 0 ; int pos2 = input . offset ; final int pos1Stop = Math . min ( lastInput . length , input . length ) ; while ( true ) { ( frontier [ pos1 ] . inputCount ) ++ ; if ( ( pos1 >= pos1Stop ) || ( ( lastInput . ints [ pos1 ] ) != ( input . ints [ pos2 ] ) ) ) { break ; } pos1 ++ ; pos2 ++ ; } final int prefixLenPlus1 = pos1 + 1 ; if ( ( frontier . length ) < ( ( input . length ) + 1 ) ) { @ SuppressWarnings ( "unchecked" ) final Builder . UnCompiledNode < T > [ ] next = new Builder . UnCompiledNode [ ArrayUtil . oversize ( ( ( input . length ) + 1 ) , NUM_BYTES_OBJECT_REF ) ] ; System . arraycopy ( frontier , 0 , next , 0 , frontier . length ) ; for ( int idx = frontier . length ; idx < ( next . length ) ; idx ++ ) { next [ idx ] = new Builder . UnCompiledNode < T > ( this , idx ) ; } frontier = next ; } compilePrevTail ( prefixLenPlus1 ) ; for ( int idx = prefixLenPlus1 ; idx <= ( input . length ) ; idx ++ ) { frontier [ ( idx - 1 ) ] . addArc ( input . ints [ ( ( ( input . offset ) + idx ) - 1 ) ] , frontier [ idx ] ) ; ( frontier [ idx ] . inputCount ) ++ ; } final Builder . UnCompiledNode < T > lastNode = frontier [ input . length ] ; lastNode . isFinal = true ; lastNode . output = NO_OUTPUT ; for ( int idx = 1 ; idx < prefixLenPlus1 ; idx ++ ) { final Builder . UnCompiledNode < T > node = frontier [ idx ] ; final Builder . UnCompiledNode < T > parentNode = frontier [ ( idx - 1 ) ] ; final T lastOutput = parentNode . getLastOutput ( input . ints [ ( ( ( input . offset ) + idx ) - 1 ) ] ) ; assert validOutput ( lastOutput ) ; final T commonOutputPrefix ; final T wordSuffix ; if ( lastOutput != ( NO_OUTPUT ) ) { commonOutputPrefix = fst . outputs . common ( output , lastOutput ) ; assert validOutput ( commonOutputPrefix ) ; wordSuffix = fst . outputs . subtract ( lastOutput , commonOutputPrefix ) ; assert validOutput ( wordSuffix ) ; parentNode . setLastOutput ( input . ints [ ( ( ( input . offset ) + idx ) - 1 ) ] , commonOutputPrefix ) ; node . prependOutput ( wordSuffix ) ; } else { commonOutputPrefix = wordSuffix = NO_OUTPUT ; } output = fst . outputs . subtract ( output , commonOutputPrefix ) ; assert validOutput ( output ) ; } if ( ( ( lastInput . length ) == ( input . length ) ) && ( prefixLenPlus1 == ( 1 + ( input . length ) ) ) ) { lastNode . output = fst . outputs . merge ( lastNode . output , output ) ; } else { frontier [ ( prefixLenPlus1 - 1 ) ] . setLastOutput ( input . ints [ ( ( ( input . offset ) + prefixLenPlus1 ) - 1 ) ] , output ) ; } <START_BUG> lastInput . copy ( input ) ; <END_BUG> } private boolean validOutput ( T output ) { } public FST < T > finish ( ) throws IOException { } private void compileAllTargets ( Builder . UnCompiledNode < T > node , int tailLength ) throws IOException { } static class Arc < T > { public int label ; public Builder . Node target ; public boolean isFinal ; public T output ; public T nextFinalOutput ; } static interface Node { boolean isCompiled ( ) { } } static final class CompiledNode implements Builder . Node { int address ; public boolean isCompiled ( ) { } } static final class UnCompiledNode < T > implements Builder . Node { final Builder < T > owner ; int numArcs ; Builder . Arc < T > [ ] arcs ; T output ; boolean isFinal ; long inputCount ; final int depth ; @ SuppressWarnings ( "unchecked" ) public UnCompiledNode ( Builder < T > owner , int depth ) { } public boolean isCompiled ( ) { } public void clear ( ) { } public T getLastOutput ( int labelToMatch ) { } public void addArc ( int label , Builder . Node target ) { } public void replaceLast ( int labelToMatch , Builder . Node target , T nextFinalOutput , boolean isFinal ) { } public void deleteLast ( int label , Builder . Node target ) { } public void setLastOutput ( int labelToMatch , T newOutput ) { }

Fix:
lastInput . copyInts ( input ) ;