Buggy code:
public abstract class FacetTestBase extends LuceneTestCase { private static final class SearchTaxoDirPair { Directory searchDir ; Directory taxoDir ; SearchTaxoDirPair ( ) { } } private static HashMap < Integer , FacetTestBase . SearchTaxoDirPair > dirsPerPartitionSize ; private static File TEST_DIR ; protected static final String CONTENT_FIELD = "content" ; protected TaxonomyReader taxoReader ; protected IndexReader indexReader ; protected IndexSearcher searcher ; @ BeforeClass public static void beforeClassFacetTestBase ( ) { } @ AfterClass public static void afterClassFacetTestBase ( ) throws Exception { } private static final String [ ] DEFAULT_CONTENT = new String [ ] { "the<seq2seq4repair_space>white<seq2seq4repair_space>car<seq2seq4repair_space>is<seq2seq4repair_space>the<seq2seq4repair_space>one<seq2seq4repair_space>I<seq2seq4repair_space>want." , "the<seq2seq4repair_space>white<seq2seq4repair_space>dog<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>belong<seq2seq4repair_space>to<seq2seq4repair_space>anyone." } ; private static final CategoryPath [ ] [ ] DEFAULT_CATEGORIES = new CategoryPath [ ] [ ] { new CategoryPath [ ] { new CategoryPath ( "root" , "a" , "f1" ) , new CategoryPath ( "root" , "a" , "f2" ) } , new CategoryPath [ ] { new CategoryPath ( "root" , "a" , "f1" ) , new CategoryPath ( "root" , "a" , "f3" ) } } ; protected List < CategoryPath > getCategories ( int doc ) { } protected int numDocsToIndex ( ) { } protected String getContent ( int doc ) { } protected final void initIndex ( ) throws Exception { } protected final void initIndex ( int partitionSize ) throws Exception { } protected final void initIndex ( int partitionSize , boolean forceDisk ) throws Exception { } protected IndexWriterConfig getIndexWriterConfig ( Analyzer analyzer ) { } protected FacetIndexingParams getFacetIndexingParams ( final int partSize ) { } protected FacetSearchParams getFacetedSearchParams ( ) { } protected FacetSearchParams getFacetedSearchParams ( int partitionSize ) { } protected void populateIndex ( RandomIndexWriter iw , TaxonomyWriter taxo , FacetIndexingParams iParams ) throws IOException { } protected void closeAll ( ) throws Exception { } protected Analyzer getAnalyzer ( ) { } protected static FacetResultNode [ ] resultNodesAsArray ( FacetResultNode parentRes ) { } protected final void indexDoc ( FacetIndexingParams iParams , RandomIndexWriter iw , TaxonomyWriter tw , String content , List < CategoryPath > categories ) throws IOException { } protected Map < CategoryPath , Integer > facetCountsTruth ( ) throws IOException { FacetIndexingParams iParams = getFacetIndexingParams ( Integer . MAX_VALUE ) ; String delim = String . valueOf ( iParams . getFacetDelimChar ( ) ) ; Map < CategoryPath , Integer > res = new HashMap < CategoryPath , Integer > ( ) ; HashSet < Term > handledTerms = new HashSet < Term > ( ) ; for ( CategoryListParams clp : iParams . getAllCategoryListParams ( ) ) { Term baseTerm = new Term ( clp . getTerm ( ) . field ( ) ) ; if ( ! ( handledTerms . add ( baseTerm ) ) ) { continue ; } Terms terms = MultiFields . getTerms ( indexReader , baseTerm . field ( ) ) ; if ( terms == null ) { continue ; } Bits liveDocs = MultiFields . getLiveDocs ( indexReader ) ; TermsEnum te = terms . iterator ( null ) ; DocsEnum de = null ; while ( ( te . next ( ) ) != null ) { <START_BUG> de = _TestUtil . docs ( random ( ) , te , liveDocs , de , false ) ; <END_BUG> int cnt = 0 ; while ( ( de . nextDoc ( ) ) != ( DocIdSetIterator . NO_MORE_DOCS ) ) { cnt ++ ; } res . put ( new CategoryPath ( te . term ( ) . utf8ToString ( ) . split ( delim ) ) , cnt ) ; } } return res ; } protected static void assertCountsAndCardinality ( Map < CategoryPath , Integer > facetCountsTruth , List < FacetResult > facetResults ) throws Exception { } private static void assertCountsAndCardinality ( Map < CategoryPath , Integer > facetCountsTruth , FacetResultNode resNode , int reqNumResults ) throws Exception { } protected static void assertSameResults ( List < FacetResult > expected , List < FacetResult > actual ) { } private static final String resStringValueOnly ( List < FacetResult > results ) { } public static class NotSameResultError extends Error { public NotSameResultError ( ) { } } }

Fix:
de = _TestUtil . docs ( random ( ) , te , liveDocs , de , 0 ) ;