Buggy code:
public class BaseTestRangeFilter extends LuceneTestCase { public static final boolean F = false ; public static final boolean T = true ; static class TestIndex { int maxR ; int minR ; boolean allowNegativeRandomInts ; Directory index ; TestIndex ( Random random , int minR , int maxR , boolean allowNegativeRandomInts ) { } } static IndexReader signedIndexReader ; static IndexReader unsignedIndexReader ; static BaseTestRangeFilter . TestIndex signedIndexDir ; static BaseTestRangeFilter . TestIndex unsignedIndexDir ; static int minId = 0 ; static int maxId ; static final int intLength = Integer . toString ( Integer . MAX_VALUE ) . length ( ) ; public static String pad ( int n ) { } @ BeforeClass public static void beforeClassBaseTestRangeFilter ( ) throws Exception { } @ AfterClass public static void afterClassBaseTestRangeFilter ( ) throws Exception { } private static IndexReader build ( Random random , BaseTestRangeFilter . TestIndex index ) throws IOException { Document doc = new Document ( ) ; Field idField = newStringField ( random , "id" , "" , YES ) ; Field intIdField = new org . apache . lucene . document . IntField ( "id_int" , 0 , Store . YES ) ; Field floatIdField = new org . apache . lucene . document . FloatField ( "id_float" , 0 , Store . YES ) ; Field longIdField = new org . apache . lucene . document . LongField ( "id_long" , 0 , Store . YES ) ; Field doubleIdField = new org . apache . lucene . document . DoubleField ( "id_double" , 0 , Store . YES ) ; Field randField = newStringField ( random , "rand" , "" , YES ) ; Field bodyField = newStringField ( random , "body" , "" , NO ) ; doc . add ( idField ) ; doc . add ( intIdField ) ; doc . add ( floatIdField ) ; doc . add ( longIdField ) ; doc . add ( doubleIdField ) ; doc . add ( randField ) ; doc . add ( bodyField ) ; RandomIndexWriter writer = new RandomIndexWriter ( random , index . index , newIndexWriterConfig ( random , TEST_VERSION_CURRENT , new MockAnalyzer ( random ) ) . setOpenMode ( CREATE ) . setMaxBufferedDocs ( TestUtil . nextInt ( random , 50 , 1000 ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ; TestUtil . reduceOpenFiles ( writer . w ) ; while ( true ) { int minCount = 0 ; int maxCount = 0 ; for ( int d = BaseTestRangeFilter . minId ; d <= ( BaseTestRangeFilter . maxId ) ; d ++ ) { idField . setStringValue ( BaseTestRangeFilter . pad ( d ) ) ; intIdField . setIntValue ( d ) ; floatIdField . setFloatValue ( d ) ; longIdField . setLongValue ( d ) ; doubleIdField . setDoubleValue ( d ) ; int r = ( index . allowNegativeRandomInts ) ? random . nextInt ( ) : random . nextInt ( Integer . MAX_VALUE ) ; if ( ( index . maxR ) < r ) { index . maxR = r ; maxCount = 1 ; } else if ( ( index . maxR ) == r ) { maxCount ++ ; } if ( r < ( index . minR ) ) { index . minR = r ; minCount = 1 ; } else if ( r == ( index . minR ) ) { minCount ++ ; } randField . setStringValue ( BaseTestRangeFilter . pad ( r ) ) ; bodyField . setStringValue ( "body" ) ; writer . addDocument ( doc ) ; } if ( ( minCount == 1 ) && ( maxCount == 1 ) ) { IndexReader ir = writer . getReader ( ) ; <START_BUG> writer . close ( ) ; <END_BUG> return ir ; } writer . deleteAll ( ) ; } } @ Test public void testPad ( ) { } }

Fix:
writer . shutdown ( ) ;