Buggy code:
public void setPreventDoubleWrite ( boolean value ) { } public static enum Throttling { ALWAYS , SOMETIMES , NEVER ; } public void setThrottling ( MockDirectoryWrapper . Throttling throttling ) { } private boolean mustSync ( ) { } @ Override public synchronized void sync ( Collection < String > names ) throws IOException { } public final synchronized long sizeInBytes ( ) throws IOException { } public synchronized void crash ( ) throws IOException { } public synchronized void clearCrash ( ) { } public void setMaxSizeInBytes ( long maxSize ) { } public long getMaxSizeInBytes ( ) { } public long getMaxUsedSizeInBytes ( ) { } public void resetMaxUsedSizeInBytes ( ) throws IOException { } public void setNoDeleteOpenFile ( boolean value ) { } public boolean getNoDeleteOpenFile ( ) { } public void setRandomIOExceptionRate ( double rate ) { } public double getRandomIOExceptionRate ( ) { } public void setRandomIOExceptionRateOnOpen ( double rate ) { } public double getRandomIOExceptionRateOnOpen ( ) { } void maybeThrowIOException ( String message ) throws IOException { } void maybeThrowIOExceptionOnOpen ( String name ) throws IOException { } @ Override public synchronized void deleteFile ( String name ) throws IOException { } private synchronized IOException fillOpenTrace ( IOException ioe , String name , boolean input ) { } private void maybeYield ( ) { } private synchronized void deleteFile ( String name , boolean forced ) throws IOException { } public synchronized Set < String > getOpenDeletedFiles ( ) { } private boolean failOnCreateOutput = true ; public void setFailOnCreateOutput ( boolean v ) { } @ Override public synchronized IndexOutput createOutput ( String name , IOContext context ) throws IOException { } private static enum Handle { Input , Output , Slice ; } synchronized void addFileHandle ( Closeable c , String name , MockDirectoryWrapper . Handle handle ) { } private boolean failOnOpenInput = true ; public void setFailOnOpenInput ( boolean v ) { } @ Override public synchronized IndexInput openInput ( String name , IOContext context ) throws IOException { } public final synchronized long getRecomputedSizeInBytes ( ) throws IOException { } public final synchronized long getRecomputedActualSizeInBytes ( ) throws IOException { } private boolean assertNoUnreferencedFilesOnClose = true ; public void setAssertNoUnrefencedFilesOnClose ( boolean v ) { } public void setWrapLockFactory ( boolean v ) { } @ Override public synchronized void close ( ) throws IOException { Set < String > pendingDeletions = new HashSet < String > ( openFilesDeleted ) ; maybeYield ( ) ; if ( ( openFiles ) == null ) { openFiles = new HashMap < String , Integer > ( ) ; openFilesDeleted = new HashSet < String > ( ) ; } if ( ( noDeleteOpenFile ) && ( ( openFiles . size ( ) ) > 0 ) ) { Exception cause = null ; Iterator < Exception > stacktraces = openFileHandles . values ( ) . iterator ( ) ; if ( stacktraces . hasNext ( ) ) cause = stacktraces . next ( ) ; throw new RuntimeException ( ( "MockDirectoryWrapper:<seq2seq4repair_space>cannot<seq2seq4repair_space>close:<seq2seq4repair_space>there<seq2seq4repair_space>are<seq2seq4repair_space>still<seq2seq4repair_space>open<seq2seq4repair_space>files:<seq2seq4repair_space>" + ( openFiles ) ) , cause ) ; } if ( ( noDeleteOpenFile ) && ( ( openLocks . size ( ) ) > 0 ) ) { throw new RuntimeException ( ( "MockDirectoryWrapper:<seq2seq4repair_space>cannot<seq2seq4repair_space>close:<seq2seq4repair_space>there<seq2seq4repair_space>are<seq2seq4repair_space>still<seq2seq4repair_space>open<seq2seq4repair_space>locks:<seq2seq4repair_space>" + ( openLocks ) ) ) ; } isOpen = false ; if ( getCheckIndexOnClose ( ) ) { randomIOExceptionRate = 0.0 ; randomIOExceptionRateOnOpen = 0.0 ; if ( DirectoryReader . indexExists ( this ) ) { if ( LuceneTestCase . VERBOSE ) { <START_BUG> System . out . println ( "\nNOTE:<seq2seq4repair_space>MockDirectoryWrapper:<seq2seq4repair_space>now<seq2seq4repair_space>crash" ) ; <END_BUG> } crash ( ) ; if ( LuceneTestCase . VERBOSE ) { System . out . println ( "\nNOTE:<seq2seq4repair_space>MockDirectoryWrapper:<seq2seq4repair_space>now<seq2seq4repair_space>run<seq2seq4repair_space>CheckIndex" ) ; } _TestUtil . checkIndex ( this , getCrossCheckTermVectorsOnClose ( ) ) ; if ( assertNoUnreferencedFilesOnClose ) { Set < String > allFiles = new HashSet < String > ( Arrays . asList ( listAll ( ) ) ) ; allFiles . removeAll ( pendingDeletions ) ; String [ ] startFiles = allFiles . toArray ( new String [ 0 ] ) ; IndexWriterConfig iwc = new IndexWriterConfig ( LuceneTestCase . TEST_VERSION_CURRENT , null ) ; iwc . setIndexDeletionPolicy ( INSTANCE ) ; new IndexWriter ( in , iwc ) . rollback ( ) ; String [ ] endFiles = in . listAll ( ) ; Set < String > startSet = new TreeSet < String > ( Arrays . asList ( startFiles ) ) ; Set < String > endSet = new TreeSet < String > ( Arrays . asList ( endFiles ) ) ; if ( ( pendingDeletions . contains ( "segments.gen" ) ) && ( endSet . contains ( "segments.gen" ) ) ) { startSet . add ( "segments.gen" ) ; if ( LuceneTestCase . VERBOSE ) { System . out . println ( "MDW:<seq2seq4repair_space>Unreferenced<seq2seq4repair_space>check:<seq2seq4repair_space>Ignoring<seq2seq4repair_space>segments.gen<seq2seq4repair_space>that<seq2seq4repair_space>we<seq2seq4repair_space>could<seq2seq4repair_space>not<seq2seq4repair_space>delete." ) ; } } for ( String file : pendingDeletions ) { if ( ( ( file . startsWith ( "segments" ) ) && ( ! ( file . equals ( "segments.gen" ) ) ) ) && ( endSet . contains ( file ) ) ) { startSet . add ( file ) ; if ( LuceneTestCase . VERBOSE ) { System . out . println ( ( ( "MDW:<seq2seq4repair_space>Unreferenced<seq2seq4repair_space>check:<seq2seq4repair_space>Ignoring<seq2seq4repair_space>segments<seq2seq4repair_space>file:<seq2seq4repair_space>" + file ) + "<seq2seq4repair_space>that<seq2seq4repair_space>we<seq2seq4repair_space>could<seq2seq4repair_space>not<seq2seq4repair_space>delete." ) ) ; } SegmentInfos sis = new SegmentInfos ( ) ; try { sis . read ( in , file ) ; } catch ( IOException ioe ) { } try { Set < String > ghosts = new HashSet < String > ( sis . files ( in , false ) ) ; for ( String s : ghosts ) { if ( ( endSet . contains ( s ) ) && ( ! ( startSet . contains ( s ) ) ) ) { assert pendingDeletions . contains ( s ) ;

Fix:
System . out . println ( "\nNOTE:<seq2seq4repair_space>MockDirectoryWrapper:<seq2seq4repair_space>now<seq2seq4repair_space>crush" ) ;