Buggy code:
class DocHelper { public static final FieldType customType ; public static final String FIELD_1_TEXT = "field<seq2seq4repair_space>one<seq2seq4repair_space>text" ; public static final String TEXT_FIELD_1_KEY = "textField1" ; public static Field textField1 ; public static final FieldType customType2 ; public static final String FIELD_2_TEXT = "field<seq2seq4repair_space>field<seq2seq4repair_space>field<seq2seq4repair_space>two<seq2seq4repair_space>text" ; public static final int [ ] FIELD_2_FREQS = new int [ ] { 3 , 1 , 1 } ; public static final String TEXT_FIELD_2_KEY = "textField2" ; public static Field textField2 ; public static final FieldType customType3 ; public static final String FIELD_3_TEXT = "aaaNoNorms<seq2seq4repair_space>aaaNoNorms<seq2seq4repair_space>bbbNoNorms" ; public static final String TEXT_FIELD_3_KEY = "textField3" ; public static Field textField3 ; public static final String KEYWORD_TEXT = "Keyword" ; public static final String KEYWORD_FIELD_KEY = "keyField" ; public static Field keyField ; public static final FieldType customType5 ; public static final String NO_NORMS_TEXT = "omitNormsText" ; public static final String NO_NORMS_KEY = "omitNorms" ; public static Field noNormsField ; public static final FieldType customType6 ; public static final String NO_TF_TEXT = "analyzed<seq2seq4repair_space>with<seq2seq4repair_space>no<seq2seq4repair_space>tf<seq2seq4repair_space>and<seq2seq4repair_space>positions" ; public static final String NO_TF_KEY = "omitTermFreqAndPositions" ; public static Field noTFField ; public static final FieldType customType7 ; public static final String UNINDEXED_FIELD_TEXT = "unindexed<seq2seq4repair_space>field<seq2seq4repair_space>text" ; public static final String UNINDEXED_FIELD_KEY = "unIndField" ; public static Field unIndField ; public static final String UNSTORED_1_FIELD_TEXT = "unstored<seq2seq4repair_space>field<seq2seq4repair_space>text" ; public static final String UNSTORED_FIELD_1_KEY = "unStoredField1" ; public static Field unStoredField1 = new org . apache . lucene . document . TextField ( DocHelper . UNSTORED_FIELD_1_KEY , DocHelper . UNSTORED_1_FIELD_TEXT , Store . NO ) ; public static final FieldType customType8 ; public static final String UNSTORED_2_FIELD_TEXT = "unstored<seq2seq4repair_space>field<seq2seq4repair_space>text" ; public static final String UNSTORED_FIELD_2_KEY = "unStoredField2" ; public static Field unStoredField2 ; public static final String LAZY_FIELD_BINARY_KEY = "lazyFieldBinary" ; public static byte [ ] LAZY_FIELD_BINARY_BYTES ; public static Field lazyFieldBinary ; public static final String LAZY_FIELD_KEY = "lazyField" ; public static final String LAZY_FIELD_TEXT = "These<seq2seq4repair_space>are<seq2seq4repair_space>some<seq2seq4repair_space>field<seq2seq4repair_space>bytes" ; public static Field lazyField = new Field ( DocHelper . LAZY_FIELD_KEY , DocHelper . LAZY_FIELD_TEXT , DocHelper . customType ) ; public static final String LARGE_LAZY_FIELD_KEY = "largeLazyField" ; public static String LARGE_LAZY_FIELD_TEXT ; public static Field largeLazyField ; public static final String FIELD_UTF1_TEXT = "field<seq2seq4repair_space>one<seq2seq4repair_space>一text" ; public static final String TEXT_FIELD_UTF1_KEY = "textField1Utf8" ; public static Field textUtfField1 = new Field ( DocHelper . TEXT_FIELD_UTF1_KEY , DocHelper . FIELD_UTF1_TEXT , DocHelper . customType ) ; public static final String FIELD_UTF2_TEXT = "field<seq2seq4repair_space>field<seq2seq4repair_space>field<seq2seq4repair_space>一two<seq2seq4repair_space>text" ; public static final int [ ] FIELD_UTF2_FREQS = new int [ ] { 3 , 1 , 1 } ; public static final String TEXT_FIELD_UTF2_KEY = "textField2Utf8" ; public static Field textUtfField2 = new Field ( DocHelper . TEXT_FIELD_UTF2_KEY , DocHelper . FIELD_UTF2_TEXT , DocHelper . customType2 ) ; public static Map < String , Object > nameValues = null ; public static Field [ ] fields = new Field [ ] { DocHelper . textField1 , DocHelper . textField2 , DocHelper . textField3 , DocHelper . keyField , DocHelper . noNormsField , DocHelper . noTFField , DocHelper . unIndField , DocHelper . unStoredField1 , DocHelper . unStoredField2 , DocHelper . textUtfField1 , DocHelper . textUtfField2 , DocHelper . lazyField , DocHelper . lazyFieldBinary , DocHelper . largeLazyField } ; public static Map < String , IndexableField > all = new HashMap < > ( ) ; public static Map < String , IndexableField > indexed = new HashMap < > ( ) ; public static Map < String , IndexableField > stored = new HashMap < > ( ) ; public static Map < String , IndexableField > unstored = new HashMap < > ( ) ; public static Map < String , IndexableField > unindexed = new HashMap < > ( ) ; public static Map < String , IndexableField > termvector = new HashMap < > ( ) ; public static Map < String , IndexableField > notermvector = new HashMap < > ( ) ; public static Map < String , IndexableField > lazy = new HashMap < > ( ) ; public static Map < String , IndexableField > noNorms = new HashMap < > ( ) ; public static Map < String , IndexableField > noTf = new HashMap < > ( ) ; private static void add ( Map < String , IndexableField > map , IndexableField field ) { } public static void setupDoc ( Document doc ) { } public static SegmentCommitInfo writeDoc ( Random random , Directory dir , Document doc ) throws IOException { } public static SegmentCommitInfo writeDoc ( Random random , Directory dir , Analyzer analyzer , Similarity similarity , Document doc ) throws IOException { IndexWriter writer = new IndexWriter ( dir , new IndexWriterConfig ( TEST_VERSION_CURRENT , analyzer ) . setSimilarity ( ( similarity == null ? IndexSearcher . getDefaultSimilarity ( ) : similarity ) ) ) ; writer . addDocument ( doc ) ; writer . commit ( ) ; SegmentCommitInfo info = writer . newestSegment ( ) ; <START_BUG> writer . close ( ) ; <END_BUG> return info ; } public static int numFields ( Document doc ) { } public static int numFields ( StoredDocument doc ) { } public static Document createDocument ( int n , String indexName , int numFields ) { } }

Fix:
writer . shutdown ( ) ;