Buggy code:
public class TestIndexWriterExceptions extends LuceneTestCase { private class IndexerThread extends Thread { IndexWriter writer ; final Random r = new Random ( random . nextLong ( ) ) ; volatile Throwable failure ; public IndexerThread ( int i , IndexWriter writer ) { } @ Override public void run ( ) { final Document doc = new Document ( ) ; doc . add ( newField ( r , "content1" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , ANALYZED ) ) ; doc . add ( newField ( r , "content6" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , ANALYZED , WITH_POSITIONS_OFFSETS ) ) ; doc . add ( newField ( r , "content2" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , NOT_ANALYZED ) ) ; doc . add ( newField ( r , "content3" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , Field . Index . NO ) ) ; doc . add ( newField ( r , "content4" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , ANALYZED ) ) ; doc . add ( newField ( r , "content5" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , NOT_ANALYZED ) ) ; doc . add ( newField ( r , "content7" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , NOT_ANALYZED , WITH_POSITIONS_OFFSETS ) ) ; <START_BUG> final Field idField = newField ( "id" , "" , YES , NOT_ANALYZED ) ; <END_BUG> doc . add ( idField ) ; final long stopTime = ( System . currentTimeMillis ( ) ) + 500 ; do { if ( VERBOSE ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>TEST:<seq2seq4repair_space>IndexerThread:<seq2seq4repair_space>cycle" ) ) ; } doFail . set ( this ) ; final String id = "" + ( r . nextInt ( 50 ) ) ; idField . setValue ( id ) ; Term idTerm = new Term ( "id" , id ) ; try { if ( r . nextBoolean ( ) ) { final List < Document > docs = new ArrayList < Document > ( ) ; final int count = _TestUtil . nextInt ( r , 1 , 20 ) ; for ( int c = 0 ; c < count ; c ++ ) { docs . add ( doc ) ; } writer . updateDocuments ( idTerm , docs ) ; } else { writer . updateDocument ( idTerm , doc ) ; } } catch ( RuntimeException re ) { if ( VERBOSE ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>EXC:<seq2seq4repair_space>" ) ) ; re . printStackTrace ( System . out ) ; } try { _TestUtil . checkIndex ( writer . getDirectory ( ) ) ; } catch ( IOException ioe ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception1" ) ) ; ioe . printStackTrace ( System . out ) ; failure = ioe ; break ; } } catch ( Throwable t ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception2" ) ) ; t . printStackTrace ( System . out ) ; failure = t ; break ; } doFail . set ( null ) ; try { writer . updateDocument ( idTerm , doc ) ; } catch ( Throwable t ) { System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>unexpected<seq2seq4repair_space>exception3" ) ) ; t . printStackTrace ( System . out ) ; failure = t ; break ; } } while ( ( System . currentTimeMillis ( ) ) < stopTime ) ; } } ThreadLocal < Thread > doFail = new ThreadLocal < Thread > ( ) ; private class MockIndexWriter extends IndexWriter { Random r = new Random ( random . nextLong ( ) ) ; public MockIndexWriter ( Directory dir , IndexWriterConfig conf ) throws IOException { } @ Override boolean testPoint ( String name ) { } } public void testRandomExceptions ( ) throws Throwable { } public void testRandomExceptionsThreads ( ) throws Throwable { } private static final class MockIndexWriter2 extends IndexWriter { public MockIndexWriter2 ( Directory dir , IndexWriterConfig conf ) throws IOException { } boolean doFail ; @ Override boolean testPoint ( String name ) { } } private static String CRASH_FAIL_MESSAGE = "I'm<seq2seq4repair_space>experiencing<seq2seq4repair_space>problems" ; private class CrashingFilter extends TokenFilter { String fieldName ; int count ; public CrashingFilter ( String fieldName , TokenStream input ) { } @ Override public boolean incrementToken ( ) throws IOException { } @ Override public void reset ( ) throws IOException { } } public void testExceptionDocumentsWriterInit ( ) throws IOException { } public void testExceptionJustBeforeFlush ( ) throws IOException { } private static final class MockIndexWriter3 extends IndexWriter { public MockIndexWriter3 ( Directory dir , IndexWriterConfig conf ) throws IOException { } boolean doFail ; boolean failed ; @ Override boolean testPoint ( String name ) { } } public void testExceptionOnMergeInit ( ) throws IOException { } public void testExceptionFromTokenStream ( ) throws IOException { } private static class FailOnlyOnFlush extends MockDirectoryWrapper . Failure { boolean doFail = false ; int count ; @ Override public void setDoFail ( ) { } @ Override public void clearDoFail ( ) { } @ Override public void eval ( MockDirectoryWrapper dir ) throws IOException { } } public void testDocumentsWriterAbort ( ) throws IOException { } public void testDocumentsWriterExceptions ( ) throws IOException { } public void testDocumentsWriterExceptionThreads ( ) throws Exception { } private static class FailOnlyInSync extends MockDirectoryWrapper . Failure { boolean didFail ; @ Override public void eval ( MockDirectoryWrapper dir ) throws IOException { } } private void addDoc ( IndexWriter writer ) throws IOException { } public void testExceptionDuringSync ( ) throws IOException { } private static class FailOnlyInCommit extends MockDirectoryWrapper . Failure { boolean fail1 ; boolean fail2 ;

Fix:
final Field idField = newField ( r , "id" , "" , YES , NOT_ANALYZED ) ;