Buggy code:
@ SuppressCodecs ( "Lucene3x" ) @ 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 { int NUM_THREADS = 3 ; int numIterations = ( TEST_NIGHTLY ) ? 7 : 3 ; for ( int iter = 0 ; iter < numIterations ; iter ++ ) { Directory dir = newDirectory ( ) ; IndexWriter writer = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) . setMaxBufferedDocs ( 10 ) . 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 , false ) ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) threads [ i ] . start ( ) ; boolean done = false ; while ( ! done ) { Thread . sleep ( 100 ) ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) if ( ( threads [ i ] . addCount ) > 0 ) { done = true ; break ; } else if ( ! ( threads [ i ] . isAlive ( ) ) ) { fail ( "thread<seq2seq4repair_space>failed<seq2seq4repair_space>before<seq2seq4repair_space>indexing<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>document" ) ; } } writer . close ( false ) ; for ( int i = 0 ; i < NUM_THREADS ; i ++ ) { threads [ i ] . join ( ) ; if ( threads [ i ] . isAlive ( ) ) fail ( "thread<seq2seq4repair_space>seems<seq2seq4repair_space>to<seq2seq4repair_space>be<seq2seq4repair_space>hung" ) ; } IndexReader reader = DirectoryReader . open ( dir ) ; <START_BUG> DocsEnum tdocs = _TestUtil . docs ( random ( ) , reader , "field" , new BytesRef ( "aaa" ) , MultiFields . getLiveDocs ( reader ) , null , false ) ; <END_BUG> int count = 0 ; while ( ( tdocs . nextDoc ( ) ) != ( DocIdSetIterator . NO_MORE_DOCS ) ) { count ++ ; } assertTrue ( ( count > 0 ) ) ; reader . close ( ) ; dir . close ( ) ; } } 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 { } } 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:
DocsEnum tdocs = _TestUtil . docs ( random ( ) , reader , "field" , new BytesRef ( "aaa" ) , MultiFields . getLiveDocs ( reader ) , null , 0 ) ;