Buggy code:
} private static class HoldsOneThing < T > { private T it ; public void set ( T it ) { } public T get ( ) { } } static final class IntCache extends FieldCacheImpl . Cache { IntCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( final AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public Bits getDocsWithField ( AtomicReader reader , String field ) throws IOException { } static final class DocsWithFieldCache extends FieldCacheImpl . Cache { DocsWithFieldCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public Floats getFloats ( AtomicReader reader , String field , boolean setDocsWithField ) throws IOException { } public Floats getFloats ( AtomicReader reader , String field , FloatParser parser , boolean setDocsWithField ) throws IOException { } static class FloatsFromArray extends Floats { private final float [ ] values ; public FloatsFromArray ( float [ ] values ) { } @ Override public float get ( int docID ) { } } static final class FloatCache extends FieldCacheImpl . Cache { FloatCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( final AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public Longs getLongs ( AtomicReader reader , String field , boolean setDocsWithField ) throws IOException { } public Longs getLongs ( AtomicReader reader , String field , FieldCache . LongParser parser , boolean setDocsWithField ) throws IOException { } static class LongsFromArray extends Longs { private final long [ ] values ; public LongsFromArray ( long [ ] values ) { } @ Override public long get ( int docID ) { } } static final class LongCache extends FieldCacheImpl . Cache { LongCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( final AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public Doubles getDoubles ( AtomicReader reader , String field , boolean setDocsWithField ) throws IOException { } public Doubles getDoubles ( AtomicReader reader , String field , FieldCache . DoubleParser parser , boolean setDocsWithField ) throws IOException { } static class DoublesFromArray extends Doubles { private final double [ ] values ; public DoublesFromArray ( double [ ] values ) { } @ Override public double get ( int docID ) { } } static final class DoubleCache extends FieldCacheImpl . Cache { DoubleCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( final AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public static class SortedDocValuesImpl extends SortedDocValues { private final Reader bytes ; private final PackedInts . Reader termOrdToBytesOffset ; private final PackedInts . Reader docToTermOrd ; private final int numOrd ; public SortedDocValuesImpl ( PagedBytes . Reader bytes , PackedInts . Reader termOrdToBytesOffset , PackedInts . Reader docToTermOrd , int numOrd ) { } @ Override public int getValueCount ( ) { } @ Override public int getOrd ( int docID ) { } @ Override public void lookupOrd ( int ord , BytesRef ret ) { } } public SortedDocValues getTermsIndex ( AtomicReader reader , String field ) throws IOException { } public SortedDocValues getTermsIndex ( AtomicReader reader , String field , float acceptableOverheadRatio ) throws IOException { } static class SortedDocValuesCache extends FieldCacheImpl . Cache { SortedDocValuesCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } private static class BinaryDocValuesImpl extends BinaryDocValues { private final Reader bytes ; private final PackedInts . Reader docToOffset ; public BinaryDocValuesImpl ( PagedBytes . Reader bytes , PackedInts . Reader docToOffset ) { } @ Override public void get ( int docID , BytesRef ret ) { } } public BinaryDocValues getTerms ( AtomicReader reader , String field ) throws IOException { } public BinaryDocValues getTerms ( AtomicReader reader , String field , float acceptableOverheadRatio ) throws IOException { } static final class BinaryDocValuesCache extends FieldCacheImpl . Cache { BinaryDocValuesCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } public SortedSetDocValues getDocTermOrds ( AtomicReader reader , String field ) throws IOException { SortedSetDocValues dv = reader . getSortedSetDocValues ( field ) ; if ( dv != null ) { return dv ; } SortedDocValues sdv = reader . getSortedDocValues ( field ) ; if ( sdv != null ) { return new org . apache . lucene . index . SingletonSortedSetDocValues ( sdv ) ; } final FieldInfo info = reader . getFieldInfos ( ) . fieldInfo ( field ) ; if ( info == null ) { return SortedSetDocValues . EMPTY ; } else if ( info . hasDocValues ( ) ) { throw new IllegalStateException ( ( ( ( "Type<seq2seq4repair_space>mismatch:<seq2seq4repair_space>" + field ) + "<seq2seq4repair_space>was<seq2seq4repair_space>indexed<seq2seq4repair_space>as<seq2seq4repair_space>" ) + ( info . getDocValuesType ( ) ) ) ) ; } else if ( ! ( info . isIndexed ( ) ) ) { return SortedSetDocValues . EMPTY ; } DocTermOrds dto = ( ( DocTermOrds ) ( caches . get ( DocTermOrds . class ) . get ( reader , new FieldCacheImpl . CacheKey ( field , null ) , false ) ) ) ; <START_BUG> return dto . iterator ( dto . getOrdTermsEnum ( reader ) ) ; <END_BUG> } static final class DocTermOrdsCache extends FieldCacheImpl . Cache { DocTermOrdsCache ( FieldCacheImpl wrapper ) { } @ Override protected Object createValue ( AtomicReader reader , FieldCacheImpl . CacheKey key , boolean setDocsWithField ) throws IOException { } } private volatile PrintStream infoStream ; public void setInfoStream ( PrintStream stream ) { } public PrintStream getInfoStream ( ) { } }

Fix:
return dto . iterator ( reader ) ;