Buggy code:
public class TestExplanations extends LuceneTestCase { protected static IndexSearcher searcher ; protected static IndexReader reader ; protected static Directory directory ; public static final String KEY = "KEY" ; public static final String FIELD = "field" ; public static final String ALTFIELD = "alt" ; @ AfterClass public static void afterClassTestExplanations ( ) throws Exception { } @ BeforeClass public static void beforeClassTestExplanations ( ) throws Exception { TestExplanations . directory = newDirectory ( ) ; RandomIndexWriter writer = new RandomIndexWriter ( random ( ) , TestExplanations . directory , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ; for ( int i = 0 ; i < ( TestExplanations . docFields . length ) ; i ++ ) { Document doc = new Document ( ) ; doc . add ( newStringField ( TestExplanations . KEY , ( "" + i ) , NO ) ) ; Field f = newTextField ( TestExplanations . FIELD , TestExplanations . docFields [ i ] , NO ) ; f . setBoost ( i ) ; doc . add ( f ) ; doc . add ( newTextField ( TestExplanations . ALTFIELD , TestExplanations . docFields [ i ] , NO ) ) ; writer . addDocument ( doc ) ; } TestExplanations . reader = writer . getReader ( ) ; <START_BUG> writer . close ( ) ; <END_BUG> TestExplanations . searcher = newSearcher ( TestExplanations . reader ) ; } protected static final String [ ] docFields = new String [ ] { "w1<seq2seq4repair_space>w2<seq2seq4repair_space>w3<seq2seq4repair_space>w4<seq2seq4repair_space>w5" , "w1<seq2seq4repair_space>w3<seq2seq4repair_space>w2<seq2seq4repair_space>w3<seq2seq4repair_space>zz" , "w1<seq2seq4repair_space>xx<seq2seq4repair_space>w2<seq2seq4repair_space>yy<seq2seq4repair_space>w3" , "w1<seq2seq4repair_space>w3<seq2seq4repair_space>xx<seq2seq4repair_space>w2<seq2seq4repair_space>yy<seq2seq4repair_space>w3<seq2seq4repair_space>zz" } ; public void qtest ( Query q , int [ ] expDocNrs ) throws Exception { } public void bqtest ( Query q , int [ ] expDocNrs ) throws Exception { } public static class ItemizedFilter extends FieldCacheTermsFilter { private static String [ ] int2str ( int [ ] terms ) { } public ItemizedFilter ( String keyField , int [ ] keys ) { } public ItemizedFilter ( int [ ] keys ) { } } public static Term [ ] ta ( String [ ] s ) { } public SpanTermQuery st ( String s ) { } public SpanNotQuery snot ( SpanQuery i , SpanQuery e ) { } public SpanOrQuery sor ( String s , String e ) { } public SpanOrQuery sor ( SpanQuery s , SpanQuery e ) { } public SpanOrQuery sor ( String s , String m , String e ) { } public SpanOrQuery sor ( SpanQuery s , SpanQuery m , SpanQuery e ) { } public SpanNearQuery snear ( String s , String e , int slop , boolean inOrder ) { } public SpanNearQuery snear ( SpanQuery s , SpanQuery e , int slop , boolean inOrder ) { } public SpanNearQuery snear ( String s , String m , String e , int slop , boolean inOrder ) { } public SpanNearQuery snear ( SpanQuery s , SpanQuery m , SpanQuery e , int slop , boolean inOrder ) { } public SpanFirstQuery sf ( String s , int b ) { } public Query optB ( Query q ) throws Exception { } public Query reqB ( Query q ) throws Exception { } public void testNoop ( ) { } }

Fix:
writer . shutdown ( ) ;