Buggy code:
public final class SegmentInfos implements Cloneable , Iterable < SegmentInfoPerCommit > { public static final int VERSION_40 = 0 ; public static final int FORMAT_SEGMENTS_GEN_CURRENT = - 2 ; public int counter ; public long version ; private long generation ; private long lastGeneration ; public Map < String , String > userData = Collections . < String , String > emptyMap ( ) ; private List < SegmentInfoPerCommit > segments = new ArrayList < SegmentInfoPerCommit > ( ) ; private static PrintStream infoStream = null ; public SegmentInfoPerCommit info ( int i ) { } public static long getLastCommitGeneration ( String [ ] files ) { } public static long getLastCommitGeneration ( Directory directory ) throws IOException { } public static String getLastCommitSegmentsFileName ( String [ ] files ) throws IOException { } public static String getLastCommitSegmentsFileName ( Directory directory ) throws IOException { } public String getSegmentsFileName ( ) { } public static long generationFromSegmentsFileName ( String fileName ) { } public String getNextSegmentFileName ( ) { } public final void read ( Directory directory , String segmentFileName ) throws IOException , CorruptIndexException { boolean success = false ; this . clear ( ) ; generation = SegmentInfos . generationFromSegmentsFileName ( segmentFileName ) ; lastGeneration = generation ; ChecksumIndexInput input = new ChecksumIndexInput ( directory . openInput ( segmentFileName , READ ) ) ; try { final int format = input . readInt ( ) ; if ( format == ( CodecUtil . CODEC_MAGIC ) ) { CodecUtil . checkHeaderNoMagic ( input , "segments" , SegmentInfos . VERSION_40 , SegmentInfos . VERSION_40 ) ; version = input . readLong ( ) ; counter = input . readInt ( ) ; int numSegments = input . readInt ( ) ; for ( int seg = 0 ; seg < numSegments ; seg ++ ) { String segName = input . readString ( ) ; Codec codec = Codec . forName ( input . readString ( ) ) ; <START_BUG> SegmentInfo info = codec . segmentInfoFormat ( ) . getSegmentInfosReader ( ) . read ( directory , segName , READ ) ; <END_BUG> info . setCodec ( codec ) ; long delGen = input . readLong ( ) ; int delCount = input . readInt ( ) ; assert delCount <= ( info . getDocCount ( ) ) ; add ( new SegmentInfoPerCommit ( info , delCount , delGen ) ) ; } userData = input . readStringStringMap ( ) ; } else { Lucene3xSegmentInfoReader . readLegacyInfos ( this , directory , input , format ) ; Codec codec = Codec . forName ( "Lucene3x" ) ; for ( SegmentInfoPerCommit info : this ) { info . info . setCodec ( codec ) ; } } final long checksumNow = input . getChecksum ( ) ; final long checksumThen = input . readLong ( ) ; if ( checksumNow != checksumThen ) { throw new CorruptIndexException ( ( ( "checksum<seq2seq4repair_space>mismatch<seq2seq4repair_space>in<seq2seq4repair_space>segments<seq2seq4repair_space>file<seq2seq4repair_space>(resource:<seq2seq4repair_space>" + input ) + ")" ) ) ; } success = true ; } finally { if ( ! success ) { this . clear ( ) ; IOUtils . closeWhileHandlingException ( input ) ; } else { input . close ( ) ; } } } public final void read ( Directory directory ) throws IOException , CorruptIndexException { } ChecksumIndexOutput pendingSegnOutput ; private void write ( Directory directory ) throws IOException { } @ Deprecated public static String write3xInfo ( Directory dir , SegmentInfo si , IOContext context ) throws IOException { } @ Override public SegmentInfos clone ( ) { } public long getVersion ( ) { } public long getGeneration ( ) { } public long getLastGeneration ( ) { } public static void setInfoStream ( PrintStream infoStream ) { } private static int defaultGenLookaheadCount = 10 ; public static void setDefaultGenLookaheadCount ( int count ) { } public static int getDefaultGenLookahedCount ( ) { } public static PrintStream getInfoStream ( ) { } private static void message ( String message ) { } public abstract static class FindSegmentsFile { final Directory directory ; public FindSegmentsFile ( Directory directory ) { } public Object run ( ) throws IOException , CorruptIndexException { } public Object run ( IndexCommit commit ) throws IOException , CorruptIndexException { } protected abstract Object doBody ( String segmentFileName ) throws IOException , CorruptIndexException { } } void updateGeneration ( SegmentInfos other ) { } final void rollbackCommit ( Directory dir ) throws IOException { } final void prepareCommit ( Directory dir ) throws IOException { } public Collection < String > files ( Directory dir , boolean includeSegmentsFile ) throws IOException { } final void finishCommit ( Directory dir ) throws IOException { } final void commit ( Directory dir ) throws IOException { } public String toString ( Directory directory ) { } public Map < String , String > getUserData ( ) { } void setUserData ( Map < String , String > data ) { } void replace ( SegmentInfos other ) { } public int totalDocCount ( ) { } public void changed ( ) { } void applyMergeChanges ( MergePolicy . OneMerge merge , boolean dropSegment ) { } List < SegmentInfoPerCommit > createBackupSegmentInfos ( ) { } void rollbackSegmentInfos ( List < SegmentInfoPerCommit > infos ) { } public Iterator < SegmentInfoPerCommit > iterator ( ) { } public List < SegmentInfoPerCommit > asList ( ) { } public int size ( ) { } public void add ( SegmentInfoPerCommit si ) { } public void addAll ( Iterable < SegmentInfoPerCommit > sis ) { } public void clear ( ) { } public void remove ( SegmentInfoPerCommit si ) { } void remove ( int index ) { } boolean contains ( SegmentInfoPerCommit si ) { } int indexOf ( SegmentInfoPerCommit si ) { } }

Fix:
SegmentInfo info = codec . segmentInfoFormat ( ) . getSegmentInfoReader ( ) . read ( directory , segName , READ ) ;