Buggy code:
public class TestBasics extends LuceneTestCase { private static IndexSearcher searcher ; private static IndexReader reader ; private static Directory directory ; static final class SimplePayloadFilter extends TokenFilter { int pos ; final PayloadAttribute payloadAttr ; final CharTermAttribute termAttr ; public SimplePayloadFilter ( TokenStream input ) { } @ Override public boolean incrementToken ( ) throws IOException { } @ Override public void reset ( ) throws IOException { } } static Analyzer simplePayloadAnalyzer ; @ BeforeClass public static void beforeClass ( ) throws Exception { TestBasics . simplePayloadAnalyzer = new Analyzer ( ) { @ Override public TokenStreamComponents createComponents ( String fieldName ) { Tokenizer tokenizer = new MockTokenizer ( MockTokenizer . SIMPLE , true ) ; return new TokenStreamComponents ( tokenizer , new TestBasics . SimplePayloadFilter ( tokenizer ) ) ; } } ; TestBasics . directory = newDirectory ( ) ; RandomIndexWriter writer = new RandomIndexWriter ( random ( ) , TestBasics . directory , newIndexWriterConfig ( TEST_VERSION_CURRENT , TestBasics . simplePayloadAnalyzer ) . setMaxBufferedDocs ( TestUtil . nextInt ( random ( ) , 100 , 1000 ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ; for ( int i = 0 ; i < 2000 ; i ++ ) { Document doc = new Document ( ) ; doc . add ( newTextField ( "field" , English . intToEnglish ( i ) , YES ) ) ; writer . addDocument ( doc ) ; } TestBasics . reader = writer . getReader ( ) ; TestBasics . searcher = newSearcher ( TestBasics . reader ) ; <START_BUG> writer . close ( ) ; <END_BUG> } @ AfterClass public static void afterClass ( ) throws Exception { } @ Test public void testTerm ( ) throws Exception { } @ Test public void testTerm2 ( ) throws Exception { } @ Test public void testPhrase ( ) throws Exception { } @ Test public void testPhrase2 ( ) throws Exception { } @ Test public void testBoolean ( ) throws Exception { } @ Test public void testBoolean2 ( ) throws Exception { } @ Test public void testSpanNearExact ( ) throws Exception { } public void testSpanTermQuery ( ) throws Exception { } @ Test public void testSpanNearUnordered ( ) throws Exception { } @ Test public void testSpanNearOrdered ( ) throws Exception { } @ Test public void testSpanNot ( ) throws Exception { } @ Test public void testSpanWithMultipleNotSingle ( ) throws Exception { } @ Test public void testSpanWithMultipleNotMany ( ) throws Exception { } @ Test public void testNpeInSpanNearWithSpanNot ( ) throws Exception { } @ Test public void testNpeInSpanNearInSpanFirstInSpanNot ( ) throws Exception { } @ Test public void testSpanNotWindowOne ( ) throws Exception { } @ Test public void testSpanNotWindowTwoBefore ( ) throws Exception { } @ Test public void testSpanNotWindowNeg ( ) throws Exception { } @ Test public void testSpanNotWindowDoubleExcludesBefore ( ) throws Exception { } @ Test public void testSpanFirst ( ) throws Exception { } @ Test public void testSpanPositionRange ( ) throws Exception { } @ Test public void testSpanPayloadCheck ( ) throws Exception { } public void testComplexSpanChecks ( ) throws Exception { } @ Test public void testSpanOr ( ) throws Exception { } @ Test public void testSpanExactNested ( ) throws Exception { } @ Test public void testSpanNearOr ( ) throws Exception { } @ Test public void testSpanComplex1 ( ) throws Exception { } @ Test public void testSpansSkipTo ( ) throws Exception { } private boolean skipToAccoringToJavaDocs ( Spans s , int target ) throws Exception { } private void checkHits ( Query query , int [ ] results ) throws IOException { } }

Fix:
writer . shutdown ( ) ;