Buggy code:
public void assertQueryEquals ( CommonQueryParserConfiguration cqpC , String field , String query , String result ) throws Exception { } public void assertEscapedQueryEquals ( String query , Analyzer a , String result ) throws Exception { } public void assertWildcardQueryEquals ( String query , boolean lowercase , String result , boolean allowLeadingWildcard ) throws Exception { } public void assertWildcardQueryEquals ( String query , boolean lowercase , String result ) throws Exception { } public void assertWildcardQueryEquals ( String query , String result ) throws Exception { } public Query getQueryDOA ( String query , Analyzer a ) throws Exception { } public void assertQueryEqualsDOA ( String query , Analyzer a , String result ) throws Exception { } public void testCJK ( ) throws Exception { } protected static class SimpleCJKTokenizer extends Tokenizer { private CharTermAttribute termAtt = addAttribute ( CharTermAttribute . class ) ; public SimpleCJKTokenizer ( ) { } @ Override public final boolean incrementToken ( ) throws IOException { } } private class SimpleCJKAnalyzer extends Analyzer { @ Override public TokenStreamComponents createComponents ( String fieldName ) { } } public void testCJKTerm ( ) throws Exception { } public void testCJKBoostedTerm ( ) throws Exception { } public void testCJKPhrase ( ) throws Exception { } public void testCJKBoostedPhrase ( ) throws Exception { } public void testCJKSloppyPhrase ( ) throws Exception { } public void testAutoGeneratePhraseQueriesOn ( ) throws Exception { } public void testSimple ( ) throws Exception { } public abstract void testDefaultOperator ( ) throws Exception { } public void testOperatorVsWhitespace ( ) throws Exception { } public void testPunct ( ) throws Exception { } public void testSlop ( ) throws Exception { } public void testNumber ( ) throws Exception { } public void testWildcard ( ) throws Exception { } public void testLeadingWildcardType ( ) throws Exception { } public void testQPA ( ) throws Exception { } public void testRange ( ) throws Exception { } public void testRangeWithPhrase ( ) throws Exception { } private String escapeDateString ( String s ) { } private String getDate ( String s , DateTools . Resolution resolution ) throws Exception { } private String getDate ( Date d , DateTools . Resolution resolution ) { } private String getLocalizedDate ( int year , int month , int day ) { } public void testDateRange ( ) throws Exception { } public void assertDateRangeQueryEquals ( CommonQueryParserConfiguration cqpC , String field , String startDate , String endDate , Date endDateInclusive , DateTools . Resolution resolution ) throws Exception { } public void testEscaped ( ) throws Exception { } public void testEscapedVsQuestionMarkAsWildcard ( ) throws Exception { } public void testQueryStringEscaping ( ) throws Exception { } public void testTabNewlineCarriageReturn ( ) throws Exception { } public void testSimpleDAO ( ) throws Exception { } public void testBoost ( ) throws Exception { } public void assertParseException ( String queryString ) throws Exception { } public void assertParseException ( String queryString , Analyzer a ) throws Exception { } public void testException ( ) throws Exception { } public void testBooleanQuery ( ) throws Exception { } public void testPrecedence ( ) throws Exception { } public abstract void testStarParsing ( ) throws Exception { } public void testEscapedWildcard ( ) throws Exception { } public void testRegexps ( ) throws Exception { } public void testStopwords ( ) throws Exception { } public void testPositionIncrement ( ) throws Exception { } public void testMatchAllDocs ( ) throws Exception { } @ SuppressWarnings ( "unused" ) private void assertHits ( int expected , String query , IndexSearcher is ) throws Exception { } @ Override public void tearDown ( ) throws Exception { } public void testPositionIncrements ( ) throws Exception { Directory dir = newDirectory ( ) ; Analyzer a = new MockAnalyzer ( random ( ) , MockTokenizer . SIMPLE , true , MockTokenFilter . ENGLISH_STOPSET ) ; IndexWriter w = new IndexWriter ( dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , a ) ) ; Document doc = new Document ( ) ; doc . add ( newTextField ( "field" , "the<seq2seq4repair_space>wizard<seq2seq4repair_space>of<seq2seq4repair_space>ozzy" , NO ) ) ; w . addDocument ( doc ) ; IndexReader r = DirectoryReader . open ( w , true ) ; <START_BUG> w . close ( ) ; <END_BUG> IndexSearcher s = newSearcher ( r ) ; Query q = getQuery ( "\"wizard<seq2seq4repair_space>of<seq2seq4repair_space>ozzy\"" , a ) ; assertEquals ( 1 , s . search ( q , 1 ) . totalHits ) ; r . close ( ) ; dir . close ( ) ; } protected static class MockSynonymFilter extends TokenFilter { CharTermAttribute termAtt = addAttribute ( CharTermAttribute . class ) ; PositionIncrementAttribute posIncAtt = addAttribute ( PositionIncrementAttribute . class ) ; boolean addSynonym = false ; public MockSynonymFilter ( TokenStream input ) { } @ Override public final boolean incrementToken ( ) throws IOException { } } protected class Analyzer1 extends Analyzer { public Analyzer1 ( ) { } @ Override public TokenStreamComponents createComponents ( String fieldName ) { } } protected class Analyzer2 extends Analyzer { public Analyzer2 ( ) { } @ Override public TokenStreamComponents createComponents ( String fieldName ) { } } public abstract void testNewFieldQuery ( ) throws Exception { } private class MockCollationFilter extends TokenFilter { private final CharTermAttribute termAtt = addAttribute ( CharTermAttribute . class ) ; protected MockCollationFilter ( TokenStream input ) { } @ Override public boolean incrementToken ( ) throws IOException { } } private class MockCollationAnalyzer extends Analyzer { @ Override public TokenStreamComponents createComponents ( String fieldName ) { } } public void testCollatedRange ( ) throws Exception { } public void testDistanceAsEditsParsing ( ) throws Exception { } public void testPhraseQueryToString ( ) throws Exception { } public void testParseWildcardAndPhraseQueries ( ) throws Exception { } public void testPhraseQueryPositionIncrements ( ) throws Exception { } public void testMatchAllQueryParsing ( ) throws Exception { } public void testNestedAndClausesFoo ( ) throws Exception { }

Fix:
w . shutdown ( ) ;