Buggy code:
TestNumericQueryParser . NUMBER_FORMAT . setMaximumIntegerDigits ( ( ( ( random ( ) . nextInt ( ) ) & 20 ) + 1 ) ) ; TestNumericQueryParser . NUMBER_FORMAT . setMinimumIntegerDigits ( ( ( ( random ( ) . nextInt ( ) ) & 20 ) + 1 ) ) ; double randomDouble ; long randomLong ; int randomInt ; float randomFloat ; while ( ( randomLong = TestNumericQueryParser . normalizeNumber ( Math . abs ( random ( ) . nextLong ( ) ) ) . longValue ( ) ) == 0L ) ; while ( ( randomDouble = TestNumericQueryParser . normalizeNumber ( Math . abs ( random ( ) . nextDouble ( ) ) ) . doubleValue ( ) ) == 0.0 ) ; while ( ( randomFloat = TestNumericQueryParser . normalizeNumber ( Math . abs ( random ( ) . nextFloat ( ) ) ) . floatValue ( ) ) == 0.0F ) ; while ( ( randomInt = TestNumericQueryParser . normalizeNumber ( Math . abs ( random ( ) . nextInt ( ) ) ) . intValue ( ) ) == 0 ) ; randomNumberMap . put ( LONG . name ( ) , randomLong ) ; randomNumberMap . put ( INT . name ( ) , randomInt ) ; randomNumberMap . put ( FLOAT . name ( ) , randomFloat ) ; randomNumberMap . put ( DOUBLE . name ( ) , randomDouble ) ; randomNumberMap . put ( TestNumericQueryParser . DATE_FIELD_NAME , randomDate ) ; TestNumericQueryParser . RANDOM_NUMBER_MAP = Collections . unmodifiableMap ( randomNumberMap ) ; TestNumericQueryParser . directory = newDirectory ( ) ; RandomIndexWriter writer = new RandomIndexWriter ( random ( ) , TestNumericQueryParser . directory , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ( ) ) ) . setMaxBufferedDocs ( TestUtil . nextInt ( random ( ) , 50 , 1000 ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ; Document doc = new Document ( ) ; HashMap < String , NumericConfig > numericConfigMap = new HashMap < > ( ) ; HashMap < String , Field > numericFieldMap = new HashMap < > ( ) ; TestNumericQueryParser . qp . setNumericConfigMap ( numericConfigMap ) ; for ( NumericType type : NumericType . values ( ) ) { numericConfigMap . put ( type . name ( ) , new NumericConfig ( TestNumericQueryParser . PRECISION_STEP , TestNumericQueryParser . NUMBER_FORMAT , type ) ) ; FieldType ft = new FieldType ( IntField . TYPE_NOT_STORED ) ; ft . setNumericType ( type ) ; ft . setStored ( true ) ; ft . setNumericPrecisionStep ( TestNumericQueryParser . PRECISION_STEP ) ; ft . freeze ( ) ; final Field field ; switch ( type ) { case INT : field = new IntField ( type . name ( ) , 0 , ft ) ; break ; case FLOAT : field = new org . apache . lucene . document . FloatField ( type . name ( ) , 0.0F , ft ) ; break ; case LONG : field = new LongField ( type . name ( ) , 0L , ft ) ; break ; case DOUBLE : field = new org . apache . lucene . document . DoubleField ( type . name ( ) , 0.0 , ft ) ; break ; default : fail ( ) ; field = null ; } numericFieldMap . put ( type . name ( ) , field ) ; doc . add ( field ) ; } numericConfigMap . put ( TestNumericQueryParser . DATE_FIELD_NAME , new NumericConfig ( TestNumericQueryParser . PRECISION_STEP , TestNumericQueryParser . DATE_FORMAT , NumericType . LONG ) ) ; FieldType ft = new FieldType ( LongField . TYPE_NOT_STORED ) ; ft . setStored ( true ) ; ft . setNumericPrecisionStep ( TestNumericQueryParser . PRECISION_STEP ) ; LongField dateField = new LongField ( TestNumericQueryParser . DATE_FIELD_NAME , 0L , ft ) ; numericFieldMap . put ( TestNumericQueryParser . DATE_FIELD_NAME , dateField ) ; doc . add ( dateField ) ; for ( TestNumericQueryParser . NumberType numberType : TestNumericQueryParser . NumberType . values ( ) ) { TestNumericQueryParser . setFieldValues ( numberType , numericFieldMap ) ; if ( VERBOSE ) System . out . println ( ( "Indexing<seq2seq4repair_space>document:<seq2seq4repair_space>" + doc ) ) ; writer . addDocument ( doc ) ; } TestNumericQueryParser . reader = writer . getReader ( ) ; TestNumericQueryParser . searcher = newSearcher ( TestNumericQueryParser . reader ) ; <START_BUG> writer . close ( ) ; <END_BUG> } private static Number getNumberType ( TestNumericQueryParser . NumberType numberType , String fieldName ) { } private static void setFieldValues ( TestNumericQueryParser . NumberType numberType , HashMap < String , Field > numericFieldMap ) { } private static int randomDateStyle ( Random random ) { } @ Test public void testInclusiveNumericRange ( ) throws Exception { } @ Test public void testInclusiveLowerNumericRange ( ) throws Exception { } @ Test public void testInclusiveUpperNumericRange ( ) throws Exception { } @ Test public void testExclusiveNumericRange ( ) throws Exception { } @ Test public void testOpenRangeNumericQuery ( ) throws Exception { } @ Test public void testSimpleNumericQuery ( ) throws Exception { } public void assertRangeQuery ( TestNumericQueryParser . NumberType lowerType , TestNumericQueryParser . NumberType upperType , boolean lowerInclusive , boolean upperInclusive , int expectedDocCount ) throws IOException , QueryNodeException { } public void assertOpenRangeQuery ( TestNumericQueryParser . NumberType boundType , String operator , int expectedDocCount ) throws IOException , QueryNodeException { } public void assertSimpleQuery ( TestNumericQueryParser . NumberType numberType , int expectedDocCount ) throws IOException , QueryNodeException { } private void testQuery ( String queryStr , int expectedDocCount ) throws IOException , QueryNodeException { } private static String numberToString ( Number number ) { } private static Number normalizeNumber ( Number number ) throws ParseException { } @ AfterClass public static void afterClass ( ) throws Exception { } }

Fix:
writer . shutdown ( ) ;