Buggy code:
private void setDiagnostics ( SegmentInfo info , String source ) { } private void setDiagnostics ( SegmentInfo info , String source , Map < String , String > details ) { } final synchronized void mergeFinish ( MergePolicy . OneMerge merge ) throws IOException { } private synchronized void setMergeDocStoreIsCompoundFile ( MergePolicy . OneMerge merge ) { } private final synchronized void closeMergeReaders ( MergePolicy . OneMerge merge , boolean suppressExceptions ) throws IOException { } private final int mergeMiddle ( MergePolicy . OneMerge merge ) throws IOException , CorruptIndexException { merge . checkAborted ( directory ) ; final String mergedName = merge . info . name ; int mergedDocCount = 0 ; SegmentInfos sourceSegments = merge . segments ; final int numSegments = sourceSegments . size ( ) ; SegmentMerger merger = new SegmentMerger ( directory , termIndexInterval , mergedName , merge , payloadProcessorProvider , ( ( FieldInfos ) ( docWriter . getFieldInfos ( ) . clone ( ) ) ) ) ; if ( ( infoStream ) != null ) { message ( ( ( ( "merging<seq2seq4repair_space>" + ( merge . segString ( directory ) ) ) + "<seq2seq4repair_space>mergeVectors=" ) + ( merge . info . getHasVectors ( ) ) ) ) ; } merge . info . setHasVectors ( merger . fieldInfos ( ) . hasVectors ( ) ) ; merge . readers = new SegmentReader [ numSegments ] ; merge . readersClone = new SegmentReader [ numSegments ] ; boolean success = false ; try { int totDocCount = 0 ; for ( int i = 0 ; i < numSegments ; i ++ ) { final SegmentInfo info = sourceSegments . info ( i ) ; SegmentReader reader = merge . readers [ i ] = readerPool . get ( info , true , IndexWriter . MERGE_READ_BUFFER_SIZE , ( - 1 ) ) ; SegmentReader clone = merge . readersClone [ i ] = ( ( SegmentReader ) ( reader . clone ( true ) ) ) ; merger . add ( clone ) ; totDocCount += clone . numDocs ( ) ; } if ( ( infoStream ) != null ) { message ( ( ( "merge:<seq2seq4repair_space>total<seq2seq4repair_space>" + totDocCount ) + "<seq2seq4repair_space>docs" ) ) ; } merge . checkAborted ( directory ) ; mergedDocCount = merge . info . docCount = merger . merge ( ) ; assert mergedDocCount == totDocCount ; if ( ( infoStream ) != null ) { message ( ( ( ( "merge<seq2seq4repair_space>store<seq2seq4repair_space>matchedCount=" + ( merger . getMatchedSubReaderCount ( ) ) ) + "<seq2seq4repair_space>vs<seq2seq4repair_space>" ) + numSegments ) ) ; } anyNonBulkMerges |= ( merger . getMatchedSubReaderCount ( ) ) != numSegments ; merge . info . setHasProx ( merger . fieldInfos ( ) . hasProx ( ) ) ; boolean useCompoundFile ; synchronized ( this ) { useCompoundFile = mergePolicy . useCompoundFile ( segmentInfos , merge . info ) ; } if ( useCompoundFile ) { success = false ; final String compoundFileName = IndexFileNames . segmentFileName ( mergedName , COMPOUND_FILE_EXTENSION ) ; try { if ( ( infoStream ) != null ) { message ( ( "create<seq2seq4repair_space>compound<seq2seq4repair_space>file<seq2seq4repair_space>" + compoundFileName ) ) ; } merger . createCompoundFile ( compoundFileName , merge . info ) ; success = true ; } catch ( IOException ioe ) { synchronized ( this ) { if ( merge . isAborted ( ) ) { } else { handleMergeException ( ioe , merge ) ; } } } catch ( Throwable t ) { handleMergeException ( t , merge ) ; } finally { if ( ! success ) { if ( ( infoStream ) != null ) { message ( "hit<seq2seq4repair_space>exception<seq2seq4repair_space>creating<seq2seq4repair_space>compound<seq2seq4repair_space>file<seq2seq4repair_space>during<seq2seq4repair_space>merge" ) ; } synchronized ( this ) { deleter . deleteFile ( compoundFileName ) ; deleter . deleteNewFiles ( merge . info . files ( ) ) ; } } } success = false ; synchronized ( this ) { deleter . deleteNewFiles ( merge . info . files ( ) ) ; if ( merge . isAborted ( ) ) { if ( ( infoStream ) != null ) { message ( "abort<seq2seq4repair_space>merge<seq2seq4repair_space>after<seq2seq4repair_space>building<seq2seq4repair_space>CFS" ) ; } deleter . deleteFile ( compoundFileName ) ; return 0 ; } } merge . info . setUseCompoundFile ( true ) ; } final int termsIndexDivisor ; final boolean loadDocStores ; <START_BUG> if ( ( poolReaders ) && ( ( mergedSegmentWarmer ) != null ) ) { <END_BUG> termsIndexDivisor = config . getReaderTermsIndexDivisor ( ) ; loadDocStores = true ; } else { termsIndexDivisor = - 1 ; loadDocStores = false ; } final SegmentReader mergedReader = readerPool . get ( merge . info , loadDocStores , BUFFER_SIZE , termsIndexDivisor ) ; try { if ( ( poolReaders ) && ( ( mergedSegmentWarmer ) != null ) ) { mergedSegmentWarmer . warm ( mergedReader ) ; } if ( ! ( commitMerge ( merge , mergedReader ) ) ) { return 0 ; } } finally { synchronized ( this ) { if ( readerPool . release ( mergedReader ) ) { checkpoint ( ) ; } } } success = true ; } finally { if ( ! success ) { closeMergeReaders ( merge , true ) ; } } return mergedDocCount ; } synchronized void addMergeException ( MergePolicy . OneMerge merge ) { } final int getBufferedDeleteTermsSize ( ) { } final int getNumBufferedDeleteTerms ( ) { } SegmentInfo newestSegment ( ) { } public synchronized String segString ( ) { } private synchronized String segString ( SegmentInfos infos ) { } private synchronized void doWait ( ) { } private boolean keepFullyDeletedSegments ; void keepFullyDeletedSegments ( ) { } private boolean filesExist ( SegmentInfos toSync ) throws IOException { } private void startCommit ( Map < String , String > commitUserData ) throws IOException { } public static boolean isLocked ( Directory directory ) throws IOException { } public static void unlock ( Directory directory ) throws IOException { }

Fix:
if ( ( mergedSegmentWarmer ) != null ) {