Buggy code:
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 ( ) { final Document doc = new Document ( ) ; FieldType customType = new FieldType ( TextField . TYPE_STORED ) ; customType . setStoreTermVectors ( true ) ; customType . setStoreTermVectorPositions ( true ) ; customType . setStoreTermVectorOffsets ( true ) ; doc . add ( newField ( "field" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd<seq2seq4repair_space>eee<seq2seq4repair_space>fff<seq2seq4repair_space>ggg<seq2seq4repair_space>hhh<seq2seq4repair_space>iii<seq2seq4repair_space>jjj" , customType ) ) ; int idUpto = 0 ; int fullCount = 0 ; final long stopTime = ( System . currentTimeMillis ( ) ) + 200 ; do { try { writer . updateDocument ( new Term ( "id" , ( "" + ( idUpto ++ ) ) ) , doc ) ; ( addCount ) ++ ; } catch ( IOException ioe ) { if ( VERBOSE ) { System . out . println ( "TEST:<seq2seq4repair_space>expected<seq2seq4repair_space>exc:" ) ; ioe . printStackTrace ( System . out ) ; } if ( ( ioe . getMessage ( ) . startsWith ( "fake<seq2seq4repair_space>disk<seq2seq4repair_space>full<seq2seq4repair_space>at" ) ) || ( ioe . getMessage ( ) . equals ( "now<seq2seq4repair_space>failing<seq2seq4repair_space>on<seq2seq4repair_space>purpose" ) ) ) { diskFull = true ; try { Thread . sleep ( 1 ) ; } catch ( InterruptedException ie ) { throw new ThreadInterruptedException ( ie ) ; } if ( ( fullCount ++ ) >= 5 ) break ; } else { if ( noErrors ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>ERROR:<seq2seq4repair_space>unexpected<seq2seq4repair_space>IOException:" ) ) ; ioe . printStackTrace ( System . out ) ; error = ioe ; } break ; } } catch ( Throwable t ) { if ( noErrors ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>ERROR:<seq2seq4repair_space>unexpected<seq2seq4repair_space>Throwable:" ) ) ; t . printStackTrace ( System . out ) ; error = t ; } break ; } } while ( ( System . currentTimeMillis ( ) ) < stopTime ) ; } } 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 { } } 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 ( ) { try { Document doc = new Document ( ) ; <START_BUG> Field field = newField ( "field" , "testData" , TYPE_STORED ) ; <END_BUG> doc . add ( field ) ; IndexWriter writer = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) ) ; iwConstructed . countDown ( ) ; startIndexing . await ( ) ; writer . addDocument ( doc ) ; writer . close ( ) ; } catch ( Throwable e ) { failed = true ; failure = e ; failure . printStackTrace ( System . out ) ; return ; } } } }

Fix:
Field field = newTextField ( "field" , "testData" , YES ) ;