Buggy code:
public class TestIndexWriterExceptions extends LuceneTestCase { private class IndexerThread extends Thread { IndexWriter writer ; final Random r = new Random ( 47 ) ; Throwable failure ; public IndexerThread ( int i , IndexWriter writer ) { } @ Override public void run ( ) { final Document doc = new Document ( ) ; doc . add ( newField ( "content1" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , ANALYZED ) ) ; doc . add ( newField ( "content6" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , ANALYZED , WITH_POSITIONS_OFFSETS ) ) ; doc . add ( newField ( "content2" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , NOT_ANALYZED ) ) ; doc . add ( newField ( "content3" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , YES , Field . Index . NO ) ) ; doc . add ( newField ( "content4" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , ANALYZED ) ) ; doc . add ( newField ( "content5" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , NOT_ANALYZED ) ) ; doc . add ( newField ( "content7" , "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" , NO , NOT_ANALYZED , WITH_POSITIONS_OFFSETS ) ) ; final Field idField = newField ( "id" , "" , YES , NOT_ANALYZED ) ; doc . add ( idField ) ; final long stopTime = ( System . currentTimeMillis ( ) ) + 500 ; do { doFail . set ( this ) ; final String id = "" + ( r . nextInt ( 50 ) ) ; idField . setValue ( id ) ; Term idTerm = new Term ( "id" , id ) ; try { writer . updateDocument ( idTerm , doc ) ; } catch ( RuntimeException re ) { if ( VERBOSE ) { <START_BUG> System . out . println ( "EXC:<seq2seq4repair_space>" ) ; <END_BUG> 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 ( 17 ) ; public MockIndexWriter ( Directory dir , IndexWriterConfig conf ) throws IOException { } @ Override boolean testPoint ( String name ) { } } public void testRandomExceptions ( ) throws Throwable { } public void testRandomExceptionsThreads ( ) throws Throwable { } }

Fix:
System . out . println ( ( ( Thread . currentThread ( ) . getName ( ) ) + ":<seq2seq4repair_space>EXC:<seq2seq4repair_space>" ) ) ;