Buggy code:
public final class FieldInfos implements Iterable < FieldInfo > { static final class FieldNumberBiMap { static final String CODEC_NAME = "GLOBAL_FIELD_MAP" ; private static final int VERSION_START = 0 ; private static final int VERSION_CURRENT = FieldInfos . FieldNumberBiMap . VERSION_START ; private final Map < Integer , String > numberToName ; private final Map < String , Integer > nameToNumber ; private int lowestUnassignedFieldNumber = - 1 ; private long lastVersion = 0 ; private long version = 0 ; FieldNumberBiMap ( ) { } synchronized int addOrGet ( String fieldName , int preferredFieldNumber ) { } synchronized void setIfNotSet ( int fieldNumber , String fieldName ) { } public synchronized long write ( IndexOutput output ) throws IOException { } public synchronized void read ( IndexInput input ) throws IOException { } public synchronized boolean isDirty ( ) { } public synchronized boolean commitLastVersion ( long version ) { } Set < Map . Entry < String , Integer > > entries ( ) { } synchronized boolean containsConsistent ( Integer number , String name ) { } } private final SortedMap < Integer , FieldInfo > byNumber = new TreeMap < Integer , FieldInfo > ( ) ; private final HashMap < String , FieldInfo > byName = new HashMap < String , FieldInfo > ( ) ; private final FieldInfos . FieldNumberBiMap globalFieldNumbers ; public static final int FORMAT_START = - 2 ; public static final int FORMAT_OMIT_POSITIONS = - 3 ; public static final int FORMAT_FLEX = - 4 ; static final int FORMAT_CURRENT = FieldInfos . FORMAT_FLEX ; static final int FORMAT_MINIMUM = FieldInfos . FORMAT_START ; static final byte IS_INDEXED = 1 ; static final byte STORE_TERMVECTOR = 2 ; static final byte STORE_POSITIONS_WITH_TERMVECTOR = 4 ; static final byte STORE_OFFSET_WITH_TERMVECTOR = 8 ; static final byte OMIT_NORMS = 16 ; static final byte STORE_PAYLOADS = 32 ; static final byte OMIT_TERM_FREQ_AND_POSITIONS = 64 ; static final byte OMIT_POSITIONS = - 128 ; private int format ; private boolean hasFreq ; private boolean hasProx ; private boolean hasVectors ; private long version ; public FieldInfos ( ) { } FieldInfos ( FieldInfos other ) { } FieldInfos ( FieldInfos . FieldNumberBiMap globalFieldNumbers ) { } public FieldInfos ( Directory d , String name ) throws IOException { } private void putInternal ( FieldInfo fi ) { } private int nextFieldNumber ( String name , int preferredFieldNumber ) { } @ Override public synchronized Object clone ( ) { } public boolean hasProx ( ) { } public boolean hasFreq ( ) { } public synchronized void addOrUpdateIndexed ( Collection < String > names , boolean storeTermVectors , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector ) { } public synchronized void addOrUpdate ( Collection < String > names , boolean isIndexed ) { } public synchronized void addOrUpdate ( String name , boolean isIndexed ) { } public synchronized void addOrUpdate ( String name , boolean isIndexed , boolean storeTermVector ) { } public synchronized void addOrUpdate ( String name , boolean isIndexed , boolean storeTermVector , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector ) { } public synchronized void addOrUpdate ( String name , boolean isIndexed , boolean storeTermVector , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector , boolean omitNorms ) { } public synchronized FieldInfo addOrUpdate ( String name , boolean isIndexed , boolean storeTermVector , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector , boolean omitNorms , boolean storePayloads , IndexOptions indexOptions , ValueType docValues ) { } public synchronized FieldInfo addOrUpdate ( String name , IndexableFieldType fieldType , boolean scorePayloads , ValueType docValues ) { } private synchronized FieldInfo addOrUpdateInternal ( String name , int preferredFieldNumber , boolean isIndexed , boolean storeTermVector , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector , boolean omitNorms , boolean storePayloads , IndexOptions indexOptions , ValueType docValues ) { } public synchronized FieldInfo add ( FieldInfo fi ) { } private FieldInfo addInternal ( String name , int fieldNumber , boolean isIndexed , boolean storeTermVector , boolean storePositionWithTermVector , boolean storeOffsetWithTermVector , boolean omitNorms , boolean storePayloads , IndexOptions indexOptions , ValueType docValuesType ) { } public int fieldNumber ( String fieldName ) { } public FieldInfo fieldInfo ( String fieldName ) { } public String fieldName ( int fieldNumber ) { } public FieldInfo fieldInfo ( int fieldNumber ) { } public Iterator < FieldInfo > iterator ( ) { } public int size ( ) { } public boolean hasVectors ( ) { } public boolean hasNorms ( ) { } public void write ( Directory d , String name ) throws IOException { } public final boolean isReadOnly ( ) { } final synchronized long getVersion ( ) { } public void write ( IndexOutput output ) throws IOException { } private void read ( IndexInput input , String fileName ) throws IOException { } void revertUncommitted ( ) { } final FieldInfos asReadOnly ( ) { } public boolean anyDocValuesFields ( ) { <START_BUG> for ( FieldInfo fi : fieldInfos ) { <END_BUG> if ( fi . hasDocValues ( ) ) { return true ; } } return false ; } }

Fix:
for ( FieldInfo fi : this ) {