shuttie opened a new issue, #13493:
URL: https://github.com/apache/lucene/issues/13493
### Description
When I use `MultiCollectorManager` which merges both
`FacetsCollectorManager` and `TopScoreDocCollectorManager` with a query not
matching any docs, I expect to get `0` as a facet count, but get NPE:
```
Cannot read the array length because "this.denseCounts" is null
java.lang.NullPointerException: Cannot read the array length because
"this.denseCounts" is null
at
__randomizedtesting.SeedInfo.seed([6C38B1BA02A289D7:8DDEDB50125C0203]:0)
at
org.apache.lucene.facet.StringValueFacetCounts.getTopChildren(StringValueFacetCounts.java:210)
at
org.apache.lucene.facet.TestStringValueFacetCounts.testNarrowSingleValued(TestStringValueFacetCounts.java:102)
at
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
```
A reproducer code:
```java
public void testNarrowSingleValued() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(new SortedSetDocValuesField("field", new BytesRef("foo")));
writer.addDocument(doc);
IndexSearcher searcher = newSearcher(writer.getReader());
writer.close();
TopScoreDocCollectorManager docCollector = new
TopScoreDocCollectorManager(10, 10);
FacetsCollectorManager facetCollector = new FacetsCollectorManager();
MultiCollectorManager merged = new MultiCollectorManager(docCollector,
facetCollector);
Object[] results = searcher.search(new MatchNoDocsQuery(), merged); //
no docs matched!
StringDocValuesReaderState state =
new StringDocValuesReaderState(searcher.getIndexReader(),
"field");
StringValueFacetCounts counts = new StringValueFacetCounts(state,
(FacetsCollector) results[1]);
FacetResult top = counts.getTopChildren(10, "field");
assertEquals(top.childCount, 0); // as no docs matched, it should be zero
IOUtils.close(searcher.getIndexReader(), dir);
}
```
The same code is working flawlessly without NPE on Lucene 9.10, but started
throwing NPE on 9.11.
### Version and environment details
* Lucene main (from d29c57e50c38c1a090395644165b34f5191246b8), also broken
on Lucene 9.11
* Eclipse Temurin JDK 21.0.3
* Linux
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]