Buggy code:
@ Slow public class TestIndexWriterWithThreads extends LuceneTestCase { private class IndexerThread extends Thread { boolean diskFull ; Throwable error ; AlreadyClosedException ace ; IndexWriter writer ; boolean noErrors ; volatile int addCount ; public IndexerThread ( IndexWriter writer , boolean noErrors ) { } @ Override public void run ( ) { } } public void testImmediateDiskFullWithThreads ( ) throws Exception { } public void testCloseWithThreads ( ) throws Exception { } public void _testMultipleThreadsFailure ( MockDirectoryWrapper . Failure failure ) throws Exception { int NUM_THREADS = 3 ; for ( int iter = 0 ; iter < 2 ; iter ++ ) { if ( VERBOSE ) { System . out . println ( ( "TEST:<seq2seq4repair_space>iter=" + iter ) ) ; } MockDirectoryWrapper dir = newMockDirectory ( ) ; IndexWriter writer = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) . setMaxBufferedDocs ( 2 ) . setMergeScheduler ( new ConcurrentMergeScheduler ( ) ) . setMergePolicy ( newLogMergePolicy ( 4 ) ) ) ; ( ( ConcurrentMergeScheduler ) ( writer . getConfig ( ) . getMergeScheduler ( ) ) ) . setSuppressExceptions ( ) ; TestIndexWriterWithThreads . IndexerThread [ ] threads = new TestIndexWriterWithThreads . IndexerThread [ NUM_THREADS ] ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) threads [ i ] = new TestIndexWriterWithThreads . IndexerThread ( writer , true ) ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) threads [ i ] . start ( ) ; Thread . sleep ( 10 ) ; dir . failOn ( failure ) ; failure . setDoFail ( ) ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) { threads [ i ] . join ( ) ; assertTrue ( "hit<seq2seq4repair_space>unexpected<seq2seq4repair_space>Throwable" , ( ( threads [ i ] . error ) == null ) ) ; } boolean success = false ; try { writer . shutdown ( false ) ; success = true ; } catch ( IOException ioe ) { failure . clearDoFail ( ) ; <START_BUG> writer . shutdown ( false ) ; <END_BUG> } if ( VERBOSE ) { System . out . println ( ( "TEST:<seq2seq4repair_space>success=" + success ) ) ; } if ( success ) { IndexReader reader = DirectoryReader . open ( dir ) ; final Bits delDocs = MultiFields . getLiveDocs ( reader ) ; for ( int j = 0 ; j < ( reader . maxDoc ( ) ) ; j ++ ) { if ( ( delDocs == null ) || ( ! ( delDocs . get ( j ) ) ) ) { reader . document ( j ) ; reader . getTermVectors ( j ) ; } } reader . close ( ) ; } dir . close ( ) ; } } public void _testSingleThreadFailure ( MockDirectoryWrapper . Failure failure ) throws IOException { } private static class FailOnlyOnAbortOrFlush extends MockDirectoryWrapper . Failure { private boolean onlyOnce ; public FailOnlyOnAbortOrFlush ( boolean onlyOnce ) { } @ Override public void eval ( MockDirectoryWrapper dir ) throws IOException { } } public void testIOExceptionDuringAbort ( ) throws IOException { } public void testIOExceptionDuringAbortOnlyOnce ( ) throws IOException { } public void testIOExceptionDuringAbortWithThreads ( ) throws Exception { } public void testIOExceptionDuringAbortWithThreadsOnlyOnce ( ) throws Exception { } private static class FailOnlyInWriteSegment extends MockDirectoryWrapper . Failure { private boolean onlyOnce ; public FailOnlyInWriteSegment ( boolean onlyOnce ) { } @ Override public void eval ( MockDirectoryWrapper dir ) throws IOException { } } public void testIOExceptionDuringWriteSegment ( ) throws IOException { } public void testIOExceptionDuringWriteSegmentOnlyOnce ( ) throws IOException { } public void testIOExceptionDuringWriteSegmentWithThreads ( ) throws Exception { } public void testIOExceptionDuringWriteSegmentWithThreadsOnlyOnce ( ) throws Exception { } public void testOpenTwoIndexWritersOnDifferentThreads ( ) throws IOException , InterruptedException { } static class DelayedIndexAndCloseRunnable extends Thread { private final Directory dir ; boolean failed = false ; Throwable failure = null ; private final CountDownLatch startIndexing = new CountDownLatch ( 1 ) ; private CountDownLatch iwConstructed ; public DelayedIndexAndCloseRunnable ( Directory dir , CountDownLatch iwConstructed ) { } public void startIndexing ( ) { } @ Override public void run ( ) { } } public void testRollbackAndCommitWithThreads ( ) throws Exception { } }

Fix:
writer . close ( ) ;