Buggy code:
public abstract class SorterTestBase extends LuceneTestCase { static final class NormsSimilarity extends Similarity { private final Similarity in ; public NormsSimilarity ( Similarity in ) { } @ Override public long computeNorm ( FieldInvertState state ) { } @ Override public SimWeight computeWeight ( float queryBoost , CollectionStatistics collectionStats , TermStatistics ... termStats ) { } @ Override public SimScorer simScorer ( SimWeight weight , AtomicReaderContext context ) throws IOException { } } static final class PositionsTokenStream extends TokenStream { private final CharTermAttribute term ; private final PayloadAttribute payload ; private final OffsetAttribute offset ; private int pos ; private int off ; public PositionsTokenStream ( ) { } @ Override public boolean incrementToken ( ) throws IOException { } void setId ( int id ) { } } protected static final String ID_FIELD = "id" ; protected static final String DOCS_ENUM_FIELD = "docs" ; protected static final String DOCS_ENUM_TERM = "$all$" ; protected static final String DOC_POSITIONS_FIELD = "positions" ; protected static final String DOC_POSITIONS_TERM = "$all$" ; protected static final String NUMERIC_DV_FIELD = "numeric" ; protected static final String NORMS_FIELD = "norm" ; protected static final String BINARY_DV_FIELD = "binary" ; protected static final String SORTED_DV_FIELD = "sorted" ; protected static final String SORTED_SET_DV_FIELD = "sorted_set" ; protected static final String TERM_VECTORS_FIELD = "term_vectors" ; private static final FieldType TERM_VECTORS_TYPE = new FieldType ( TextField . TYPE_NOT_STORED ) ; private static final FieldType POSITIONS_TYPE = new FieldType ( TextField . TYPE_NOT_STORED ) ; protected static Directory dir ; protected static AtomicReader reader ; protected static Integer [ ] sortedValues ; private static Document doc ( final int id , SorterTestBase . PositionsTokenStream positions ) { } public static void createIndex ( Directory dir , int numDocs , Random random ) throws IOException { List < Integer > ids = new ArrayList < > ( ) ; for ( int i = 0 ; i < numDocs ; i ++ ) { ids . add ( Integer . valueOf ( ( i * 10 ) ) ) ; } Collections . shuffle ( ids , random ) ; if ( VERBOSE ) { System . out . println ( ( "Shuffled<seq2seq4repair_space>IDs<seq2seq4repair_space>for<seq2seq4repair_space>indexing:<seq2seq4repair_space>" + ( Arrays . toString ( ids . toArray ( ) ) ) ) ) ; } SorterTestBase . PositionsTokenStream positions = new SorterTestBase . PositionsTokenStream ( ) ; IndexWriterConfig conf = newIndexWriterConfig ( TEST_VERSION_CURRENT , new MockAnalyzer ( random ) ) ; conf . setMaxBufferedDocs ( 4 ) ; conf . setSimilarity ( new SorterTestBase . NormsSimilarity ( conf . getSimilarity ( ) ) ) ; RandomIndexWriter writer = new RandomIndexWriter ( random , dir , conf ) ; writer . setDoRandomForceMerge ( false ) ; for ( int id : ids ) { writer . addDocument ( SorterTestBase . doc ( id , positions ) ) ; } writer . commit ( ) ; for ( Integer id : ids ) { if ( ( random . nextDouble ( ) ) < 0.2 ) { if ( VERBOSE ) { System . out . println ( ( "delete<seq2seq4repair_space>doc_id<seq2seq4repair_space>" + id ) ) ; } writer . deleteDocuments ( new Term ( SorterTestBase . ID_FIELD , id . toString ( ) ) ) ; } } <START_BUG> writer . close ( ) ; <END_BUG> } @ BeforeClass public static void beforeClassSorterTestBase ( ) throws Exception { } @ AfterClass public static void afterClassSorterTestBase ( ) throws Exception { } @ Test public void testBinaryDocValuesField ( ) throws Exception { } @ Test public void testDocsAndPositionsEnum ( ) throws Exception { } Bits randomLiveDocs ( int maxDoc ) { } @ Test public void testDocsEnum ( ) throws Exception { } @ Test public void testNormValues ( ) throws Exception { } @ Test public void testNumericDocValuesField ( ) throws Exception { } @ Test public void testSortedDocValuesField ( ) throws Exception { } @ Test public void testSortedSetDocValuesField ( ) throws Exception { } @ Test public void testTermVectors ( ) throws Exception { } }

Fix:
writer . shutdown ( ) ;