Buggy code:
public class TestParser extends LuceneTestCase { private static CoreParser builder ; private static Directory dir ; private static IndexReader reader ; private static IndexSearcher searcher ; @ BeforeClass public static void beforeClass ( ) throws Exception { Analyzer analyzer = new org . apache . lucene . analysis . MockAnalyzer ( random ( ) , MockTokenizer . WHITESPACE , true , MockTokenFilter . ENGLISH_STOPSET ) ; TestParser . builder = new CorePlusExtensionsParser ( "contents" , analyzer ) ; BufferedReader d = new BufferedReader ( new InputStreamReader ( TestParser . class . getResourceAsStream ( "reuters21578.txt" ) , "US-ASCII" ) ) ; TestParser . dir = newDirectory ( ) ; <START_BUG> IndexWriter writer = new IndexWriter ( TestParser . dir , newIndexWriterConfig ( LUCENE_40 , analyzer ) ) ; <END_BUG> String line = d . readLine ( ) ; while ( line != null ) { int endOfDate = line . indexOf ( '\t' ) ; String date = line . substring ( 0 , endOfDate ) . trim ( ) ; String content = line . substring ( endOfDate ) . trim ( ) ; Document doc = new Document ( ) ; doc . add ( newTextField ( "date" , date , YES ) ) ; doc . add ( newTextField ( "contents" , content , YES ) ) ; doc . add ( new org . apache . lucene . document . IntField ( "date2" , Integer . valueOf ( date ) , Store . NO ) ) ; writer . addDocument ( doc ) ; line = d . readLine ( ) ; } d . close ( ) ; writer . close ( ) ; TestParser . reader = DirectoryReader . open ( TestParser . dir ) ; TestParser . searcher = newSearcher ( TestParser . reader ) ; } @ AfterClass public static void afterClass ( ) throws Exception { } public void testSimpleXML ( ) throws IOException , ParserException { } public void testSimpleTermsQueryXML ( ) throws IOException , ParserException { } public void testBooleanQueryXML ( ) throws IOException , ParserException { } public void testDisjunctionMaxQueryXML ( ) throws IOException , ParserException { } public void testRangeFilterQueryXML ( ) throws IOException , ParserException { } public void testUserQueryXML ( ) throws IOException , ParserException { } public void testCustomFieldUserQueryXML ( ) throws IOException , ParserException { } public void testLikeThisQueryXML ( ) throws Exception { } public void testBoostingQueryXML ( ) throws Exception { } public void testFuzzyLikeThisQueryXML ( ) throws Exception { } public void testTermsFilterXML ( ) throws Exception { } public void testBoostingTermQueryXML ( ) throws Exception { } public void testSpanTermXML ( ) throws Exception { } public void testConstantScoreQueryXML ( ) throws Exception { } public void testMatchAllDocsPlusFilterXML ( ) throws IOException , ParserException { } public void testBooleanFilterXML ( ) throws IOException , ParserException { } public void testNestedBooleanQuery ( ) throws IOException , ParserException { } public void testCachedFilterXML ( ) throws IOException , ParserException { } public void testDuplicateFilterQueryXML ( ) throws IOException , ParserException { } public void testNumericRangeFilterQueryXML ( ) throws IOException , ParserException { } public void testNumericRangeQueryQueryXML ( ) throws IOException , ParserException { } private Query parse ( String xmlFileName ) throws IOException , ParserException { } private void dumpResults ( String qType , Query q , int numDocs ) throws IOException { } }

Fix:
IndexWriter writer = new IndexWriter ( TestParser . dir , newIndexWriterConfig ( TEST_VERSION_CURRENT , analyzer ) ) ;