Buggy code:
public class SegmentReader extends IndexReader implements Cloneable { protected boolean readOnly ; private SegmentInfo si ; private int readBufferSize ; CloseableThreadLocal < FieldsReader > fieldsReaderLocal = new SegmentReader . FieldsReaderLocal ( ) ; CloseableThreadLocal < TermVectorsReader > termVectorsLocal = new CloseableThreadLocal < TermVectorsReader > ( ) ; BitVector deletedDocs = null ; AtomicInteger deletedDocsRef = null ; private boolean deletedDocsDirty = false ; private boolean normsDirty = false ; private int pendingDeleteCount ; private boolean rollbackHasChanges = false ; private boolean rollbackDeletedDocsDirty = false ; private boolean rollbackNormsDirty = false ; private SegmentInfo rollbackSegmentInfo ; private int rollbackPendingDeleteCount ; private IndexInput singleNormStream ; private AtomicInteger singleNormRef ; SegmentReader . CoreReaders core ; static final class CoreReaders { private final AtomicInteger ref = new AtomicInteger ( 1 ) ; final String segment ; final FieldInfos fieldInfos ; final IndexInput freqStream ; final IndexInput proxStream ; final TermInfosReader tisNoIndex ; final Directory dir ; final Directory cfsDir ; final int readBufferSize ; final int termsIndexDivisor ; private final SegmentReader origInstance ; TermInfosReader tis ; FieldsReader fieldsReaderOrig ; TermVectorsReader termVectorsReaderOrig ; CompoundFileReader cfsReader ; CompoundFileReader storeCFSReader ; CoreReaders ( SegmentReader origInstance , Directory dir , SegmentInfo si , int readBufferSize , int termsIndexDivisor ) throws IOException { } synchronized TermVectorsReader getTermVectorsReaderOrig ( ) { } synchronized FieldsReader getFieldsReaderOrig ( ) { } synchronized void incRef ( ) { } synchronized Directory getCFSReader ( ) { } synchronized TermInfosReader getTermsReader ( ) { } synchronized boolean termsIndexIsLoaded ( ) { } synchronized void loadTermsIndex ( SegmentInfo si , int termsIndexDivisor ) throws IOException { } synchronized void decRef ( ) throws IOException { } synchronized void openDocStores ( SegmentInfo si ) throws IOException { assert si . name . equals ( segment ) ; if ( ( fieldsReaderOrig ) == null ) { final Directory storeDir ; if ( ( si . getDocStoreOffset ( ) ) != ( - 1 ) ) { if ( si . getDocStoreIsCompoundFile ( ) ) { assert ( storeCFSReader ) == null ; storeCFSReader = new CompoundFileReader ( dir , IndexFileNames . segmentFileName ( si . getDocStoreSegment ( ) , COMPOUND_FILE_STORE_EXTENSION ) , readBufferSize ) ; storeDir = storeCFSReader ; assert storeDir != null ; } else { storeDir = dir ; assert storeDir != null ; } } else if ( si . getUseCompoundFile ( ) ) { if ( ( cfsReader ) == null ) { cfsReader = new CompoundFileReader ( dir , IndexFileNames . segmentFileName ( segment , COMPOUND_FILE_EXTENSION ) , readBufferSize ) ; } storeDir = cfsReader ; assert storeDir != null ; } else { storeDir = dir ; assert storeDir != null ; } final String storesSegment ; if ( ( si . getDocStoreOffset ( ) ) != ( - 1 ) ) { storesSegment = si . getDocStoreSegment ( ) ; } else { storesSegment = segment ; } fieldsReaderOrig = new FieldsReader ( storeDir , storesSegment , fieldInfos , readBufferSize , si . getDocStoreOffset ( ) , si . docCount ) ; if ( ( ( si . getDocStoreOffset ( ) ) == ( - 1 ) ) && ( ( fieldsReaderOrig . size ( ) ) != ( si . docCount ) ) ) { throw new CorruptIndexException ( ( ( ( ( ( "doc<seq2seq4repair_space>counts<seq2seq4repair_space>differ<seq2seq4repair_space>for<seq2seq4repair_space>segment<seq2seq4repair_space>" + ( segment ) ) + ":<seq2seq4repair_space>fieldsReader<seq2seq4repair_space>shows<seq2seq4repair_space>" ) + ( fieldsReaderOrig . size ( ) ) ) + "<seq2seq4repair_space>but<seq2seq4repair_space>segmentInfo<seq2seq4repair_space>shows<seq2seq4repair_space>" ) + ( si . docCount ) ) ) ; } <START_BUG> if ( fieldInfos . hasVectors ( ) ) { <END_BUG> termVectorsReaderOrig = new TermVectorsReader ( storeDir , storesSegment , fieldInfos , readBufferSize , si . getDocStoreOffset ( ) , si . docCount ) ; } } } } private class FieldsReaderLocal extends CloseableThreadLocal < FieldsReader > { @ Override protected FieldsReader initialValue ( ) { } } final class Norm implements Cloneable { private int refCount = 1 ; private SegmentReader . Norm origNorm ; private IndexInput in ; private long normSeek ; private AtomicInteger bytesRef ; private byte [ ] bytes ; private boolean dirty ; private int number ; private boolean rollbackDirty ; public Norm ( IndexInput in , int number , long normSeek ) { } public synchronized void incRef ( ) { } private void closeInput ( ) throws IOException { } public synchronized void decRef ( ) throws IOException { } public synchronized void bytes ( byte [ ] bytesOut , int offset , int len ) throws IOException { } public synchronized byte [ ] bytes ( ) throws IOException { } AtomicInteger bytesRef ( ) { } public synchronized byte [ ] copyOnWrite ( ) throws IOException { } @ Override public synchronized Object clone ( ) { } public void reWrite ( SegmentInfo si ) throws IOException { } } Map < String , SegmentReader . Norm > norms = new HashMap < String , SegmentReader . Norm > ( ) ; public static SegmentReader get ( boolean readOnly , SegmentInfo si , int termInfosIndexDivisor ) throws IOException , CorruptIndexException { } public static SegmentReader get ( boolean readOnly , Directory dir , SegmentInfo si , int readBufferSize , boolean doOpenStores , int termInfosIndexDivisor ) throws IOException , CorruptIndexException { } void openDocStores ( ) throws IOException { } private boolean checkDeletedCounts ( ) throws IOException { } private void loadDeletedDocs ( ) throws IOException { } protected byte [ ] cloneNormBytes ( byte [ ] bytes ) { } protected BitVector cloneDeletedDocs ( BitVector bv ) { } @ Override public final synchronized Object clone ( ) { } @ Override public final synchronized IndexReader clone ( boolean openReadOnly ) throws IOException , CorruptIndexException { } @ Override public synchronized IndexReader reopen ( ) throws IOException , CorruptIndexException { } @ Override public synchronized IndexReader reopen ( boolean openReadOnly ) throws IOException , CorruptIndexException { } synchronized SegmentReader reopenSegment ( SegmentInfo si , boolean doClone , boolean openReadOnly ) throws IOException , CorruptIndexException { }

Fix:
if ( si . getHasVectors ( ) ) {