Buggy code:
public final class FuzzyTermsEnum extends TermsEnum { private TermsEnum actualEnum ; private BoostAttribute actualBoostAtt ; private final BoostAttribute boostAtt = attributes ( ) . addAttribute ( BoostAttribute . class ) ; private final MaxNonCompetitiveBoostAttribute maxBoostAtt ; private final FuzzyTermsEnum . LevenshteinAutomataAttribute dfaAtt ; private float bottom ; private BytesRef bottomTerm ; private final Comparator < BytesRef > termComparator = BytesRef . getUTF8SortedAsUnicodeComparator ( ) ; private final float minSimilarity ; private final float scale_factor ; private final int termLength ; private int maxEdits ; private final boolean raw ; private final Terms terms ; private final Term term ; private final int [ ] termText ; private final int realPrefixLength ; public FuzzyTermsEnum ( Terms terms , AttributeSource atts , Term term , final float minSimilarity , final int prefixLength ) throws IOException { } private TermsEnum getAutomatonEnum ( int editDistance , BytesRef lastTerm ) throws IOException { } private List < CompiledAutomaton > initAutomata ( int maxDistance ) { } private void setEnum ( TermsEnum actualEnum ) { } private void bottomChanged ( BytesRef lastTerm , boolean init ) throws IOException { } private int initialMaxDistance ( float minimumSimilarity , int termLen ) { } private float calculateMaxBoost ( int nEdits ) { } private BytesRef queuedBottom = null ; @ Override public BytesRef next ( ) throws IOException { if ( ( queuedBottom ) != null ) { bottomChanged ( queuedBottom , false ) ; queuedBottom = null ; } BytesRef term = actualEnum . next ( ) ; boostAtt . setBoost ( actualBoostAtt . getBoost ( ) ) ; final float bottom = maxBoostAtt . getMaxNonCompetitiveBoost ( ) ; final BytesRef bottomTerm = maxBoostAtt . getCompetitiveTerm ( ) ; if ( ( term != null ) && ( ( bottom != ( this . bottom ) ) || ( bottomTerm != ( this . bottomTerm ) ) ) ) { this . bottom = bottom ; this . bottomTerm = bottomTerm ; <START_BUG> queuedBottom = new BytesRef ( term ) ; <END_BUG> } return term ; } @ Override public int docFreq ( ) throws IOException { } @ Override public long totalTermFreq ( ) throws IOException { } @ Override public DocsEnum docs ( Bits liveDocs , DocsEnum reuse ) throws IOException { } @ Override public DocsAndPositionsEnum docsAndPositions ( Bits liveDocs , DocsAndPositionsEnum reuse ) throws IOException { } @ Override public void seekExact ( BytesRef term , TermState state ) throws IOException { } @ Override public TermState termState ( ) throws IOException { } @ Override public Comparator < BytesRef > getComparator ( ) throws IOException { } @ Override public long ord ( ) throws IOException { } @ Override public boolean seekExact ( BytesRef text , boolean useCache ) throws IOException { } @ Override public SeekStatus seekCeil ( BytesRef text , boolean useCache ) throws IOException { } @ Override public void seekExact ( long ord ) throws IOException { } @ Override public BytesRef term ( ) throws IOException { } private class AutomatonFuzzyTermsEnum extends FilteredTermsEnum { private final ByteRunAutomaton [ ] matchers ; private final BytesRef termRef ; private final BoostAttribute boostAtt = attributes ( ) . addAttribute ( BoostAttribute . class ) ; public AutomatonFuzzyTermsEnum ( TermsEnum tenum , CompiledAutomaton [ ] compiled ) throws IOException { } @ Override protected AcceptStatus accept ( BytesRef term ) { } final boolean matches ( BytesRef term , int k ) { } } private class LinearFuzzyTermsEnum extends FilteredTermsEnum { private int [ ] d ; private int [ ] p ; private final int [ ] text ; private final BoostAttribute boostAtt = attributes ( ) . addAttribute ( BoostAttribute . class ) ; public LinearFuzzyTermsEnum ( ) throws IOException { } private final BytesRef prefixBytesRef ; private final IntsRef utf32 = new IntsRef ( 20 ) ; @ Override protected final AcceptStatus accept ( BytesRef term ) { } private final float similarity ( final int [ ] target , int offset , int length ) { } private int calculateMaxDistance ( int m ) { } } public float getMinSimilarity ( ) { } public float getScaleFactor ( ) { } public static interface LevenshteinAutomataAttribute extends Attribute { public List < CompiledAutomaton > automata ( ) { } } public static final class LevenshteinAutomataAttributeImpl extends AttributeImpl implements FuzzyTermsEnum . LevenshteinAutomataAttribute { private final List < CompiledAutomaton > automata = new ArrayList < CompiledAutomaton > ( ) ; public List < CompiledAutomaton > automata ( ) { } @ Override public void clear ( ) { } @ Override public int hashCode ( ) { } @ Override public boolean equals ( Object other ) { } @ Override public void copyTo ( AttributeImpl target ) { } } }

Fix:
queuedBottom = BytesRef . deepCopyOf ( term ) ;