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 { } 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 { dir . setAssertNoUnrefencedFilesOnClose ( false ) ; if ( doFail ) { StackTraceElement [ ] trace = new Exception ( ) . getStackTrace ( ) ; boolean sawAbortOrFlushDoc = false ; boolean sawClose = false ; boolean sawMerge = false ; for ( int i = 0 ; i < ( trace . length ) ; i ++ ) { if ( ( "abort" . equals ( trace [ i ] . getMethodName ( ) ) ) || ( "finishDocument" . equals ( trace [ i ] . getMethodName ( ) ) ) ) { sawAbortOrFlushDoc = true ; } <START_BUG> if ( "merge" . equals ( trace [ i ] ) ) { <END_BUG> sawMerge = true ; } if ( "close" . equals ( trace [ i ] . getMethodName ( ) ) ) { sawClose = true ; } } if ( ( sawAbortOrFlushDoc && ( ! sawClose ) ) && ( ! sawMerge ) ) { if ( onlyOnce ) doFail = false ; throw new IOException ( "now<seq2seq4repair_space>failing<seq2seq4repair_space>on<seq2seq4repair_space>purpose" ) ; } } } } 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 { if ( doFail ) { StackTraceElement [ ] trace = new Exception ( ) . getStackTrace ( ) ; for ( int i = 0 ; i < ( trace . length ) ; i ++ ) { if ( ( "flush" . equals ( trace [ i ] . getMethodName ( ) ) ) && ( "org.apache.lucene.index.DocFieldProcessor" . equals ( trace [ i ] . getClassName ( ) ) ) ) { if ( onlyOnce ) doFail = false ; throw new IOException ( "now<seq2seq4repair_space>failing<seq2seq4repair_space>on<seq2seq4repair_space>purpose" ) ; } } } } } 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:
if ( "merge" . equals ( trace [ i ] . getMethodName ( ) ) ) {