Buggy code:
@ Ignore ( "broken:<seq2seq4repair_space>see<seq2seq4repair_space>https:////issues.apache.org//jira//browse//LUCENE-2822" ) public class TestTimeLimitingCollector extends LuceneTestCase { private static final int SLOW_DOWN = 3 ; private static final long TIME_ALLOWED = 17 * ( TestTimeLimitingCollector . SLOW_DOWN ) ; private static final double MULTI_THREAD_SLACK = 7 ; private static final int N_DOCS = 3000 ; private static final int N_THREADS = 50 ; private IndexSearcher searcher ; private Directory directory ; private IndexReader reader ; private final String FIELD_NAME = "body" ; private Query query ; @ Override public void setUp ( ) throws Exception { super . setUp ( ) ; final String [ ] docText = new String [ ] { "docThatNeverMatchesSoWeCanRequireLastDocCollectedToBeGreaterThanZero" , "one<seq2seq4repair_space>blah<seq2seq4repair_space>three" , "one<seq2seq4repair_space>foo<seq2seq4repair_space>three<seq2seq4repair_space>multiOne" , "one<seq2seq4repair_space>foobar<seq2seq4repair_space>three<seq2seq4repair_space>multiThree" , "blueberry<seq2seq4repair_space>pancakes" , "blueberry<seq2seq4repair_space>pie" , "blueberry<seq2seq4repair_space>strudel" , "blueberry<seq2seq4repair_space>pizza" } ; directory = newDirectory ( ) ; <START_BUG> RandomIndexWriter iw = new RandomIndexWriter ( random , directory ) ; <END_BUG> for ( int i = 0 ; i < ( TestTimeLimitingCollector . N_DOCS ) ; i ++ ) { add ( docText [ ( i % ( docText . length ) ) ] , iw ) ; } reader = iw . getReader ( ) ; iw . close ( ) ; searcher = newSearcher ( reader ) ; String qtxt = "one" ; for ( int i = 1 ; i < ( docText . length ) ; i ++ ) { qtxt += '<seq2seq4repair_space>' + ( docText [ i ] ) ; } QueryParser queryParser = new QueryParser ( TEST_VERSION_CURRENT , FIELD_NAME , new org . apache . lucene . analysis . MockAnalyzer ( random ) ) ; query = queryParser . parse ( qtxt ) ; searcher . search ( query , null , 1000 ) ; } @ Override public void tearDown ( ) throws Exception { } private void add ( String value , RandomIndexWriter iw ) throws IOException { } private void search ( Collector collector ) throws Exception { } public void testSearch ( ) { } private void doTestSearch ( ) { } private Collector createTimedCollector ( TestTimeLimitingCollector . MyHitCollector hc , long timeAllowed , boolean greedy ) { } public void testTimeoutGreedy ( ) { } public void testTimeoutNotGreedy ( ) { } private void doTestTimeout ( boolean multiThreaded , boolean greedy ) { } private long maxTime ( boolean multiThreaded ) { } private String maxTimeStr ( boolean multiThreaded ) { } public void testModifyResolution ( ) { } public void testSearchMultiThreaded ( ) throws Exception { } public void testTimeoutMultiThreaded ( ) throws Exception { } private void doTestMultiThreads ( final boolean withTimeout ) throws Exception { } private class MyHitCollector extends Collector { private final BitSet bits = new BitSet ( ) ; private int slowdown = 0 ; private int lastDocCollected = - 1 ; private int docBase = 0 ; public void setSlowDown ( int milliseconds ) { } public int hitCount ( ) { } public int getLastDocCollected ( ) { } @ Override public void setScorer ( Scorer scorer ) throws IOException { } @ Override public void collect ( final int doc ) throws IOException { } @ Override public void setNextReader ( AtomicReaderContext context ) { } @ Override public boolean acceptsDocsOutOfOrder ( ) { } } }

Fix:
RandomIndexWriter iw = new RandomIndexWriter ( random , directory , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ;