Buggy code:
public class TestAtomicUpdate extends LuceneTestCase { private abstract static class TimedThread extends Thread { volatile boolean failed ; int count ; private static float RUN_TIME_MSEC = atLeast ( 500 ) ; private TestAtomicUpdate . TimedThread [ ] allThreads ; public abstract void doWork ( ) throws Throwable { } TimedThread ( TestAtomicUpdate . TimedThread [ ] threads ) { } @ Override public void run ( ) { } private boolean anyErrors ( ) { } } private static class IndexerThread extends TestAtomicUpdate . TimedThread { IndexWriter writer ; public IndexerThread ( IndexWriter writer , TestAtomicUpdate . TimedThread [ ] threads ) { } @ Override public void doWork ( ) throws Exception { } } private static class SearcherThread extends TestAtomicUpdate . TimedThread { private Directory directory ; public SearcherThread ( Directory directory , TestAtomicUpdate . TimedThread [ ] threads ) { } @ Override public void doWork ( ) throws Throwable { } } public void runTest ( Directory directory ) throws Exception { TestAtomicUpdate . TimedThread [ ] threads = new TestAtomicUpdate . TimedThread [ 4 ] ; IndexWriterConfig conf = new IndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) . setMaxBufferedDocs ( 7 ) ; ( ( TieredMergePolicy ) ( conf . getMergePolicy ( ) ) ) . setMaxMergeAtOnce ( 3 ) ; IndexWriter writer = RandomIndexWriter . mockIndexWriter ( directory , conf , random ( ) ) ; for ( int i = 0 ; i < 100 ; i ++ ) { Document d = new Document ( ) ; d . add ( newStringField ( "id" , Integer . toString ( i ) , YES ) ) ; d . add ( newTextField ( "contents" , English . intToEnglish ( i ) , NO ) ) ; if ( ( ( i - 1 ) % 7 ) == 0 ) { writer . commit ( ) ; } writer . addDocument ( d ) ; } writer . commit ( ) ; IndexReader r = DirectoryReader . open ( directory ) ; assertEquals ( 100 , r . numDocs ( ) ) ; r . close ( ) ; TestAtomicUpdate . IndexerThread indexerThread = new TestAtomicUpdate . IndexerThread ( writer , threads ) ; threads [ 0 ] = indexerThread ; indexerThread . start ( ) ; TestAtomicUpdate . IndexerThread indexerThread2 = new TestAtomicUpdate . IndexerThread ( writer , threads ) ; threads [ 1 ] = indexerThread2 ; indexerThread2 . start ( ) ; TestAtomicUpdate . SearcherThread searcherThread1 = new TestAtomicUpdate . SearcherThread ( directory , threads ) ; threads [ 2 ] = searcherThread1 ; searcherThread1 . start ( ) ; TestAtomicUpdate . SearcherThread searcherThread2 = new TestAtomicUpdate . SearcherThread ( directory , threads ) ; threads [ 3 ] = searcherThread2 ; searcherThread2 . start ( ) ; indexerThread . join ( ) ; indexerThread2 . join ( ) ; searcherThread1 . join ( ) ; searcherThread2 . join ( ) ; <START_BUG> writer . close ( ) ; <END_BUG> assertTrue ( "hit<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception<seq2seq4repair_space>in<seq2seq4repair_space>indexer" , ( ! ( indexerThread . failed ) ) ) ; assertTrue ( "hit<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception<seq2seq4repair_space>in<seq2seq4repair_space>indexer2" , ( ! ( indexerThread2 . failed ) ) ) ; assertTrue ( "hit<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception<seq2seq4repair_space>in<seq2seq4repair_space>search1" , ( ! ( searcherThread1 . failed ) ) ) ; assertTrue ( "hit<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception<seq2seq4repair_space>in<seq2seq4repair_space>search2" , ( ! ( searcherThread2 . failed ) ) ) ; } public void testAtomicUpdates ( ) throws Exception { } }

Fix:
writer . shutdown ( ) ;