diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index d199da17938..7ee1b813a75 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -149,6 +149,9 @@ Bug Fixes * LUCENE-10533: SpellChecker.formGrams is missing bounds check (Kevin Risden) +* LUCENE-10529: Properly handle when TestTaxonomyFacetAssociations test case randomly indexes + no documents instead of throwing an NPE. (Greg Miller) + Build --------------------- diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java index 3edd49cd61f..eb6088922eb 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java @@ -427,9 +427,16 @@ public class TestTaxonomyFacetAssociations extends FacetTestCase { } FacetResult facetResult = facets.getTopChildren(10, dim); - assertEquals(dim, facetResult.dim); - assertEquals(aggregatedValue, facetResult.value.intValue()); - assertEquals(expected.size(), facetResult.childCount); + + if (expected.isEmpty()) { + // If we hit the rare random case where nothing is indexed for the dim, we expect a null + // facetResult (see: LUCENE-10529) + assertNull(facetResult); + } else { + assertEquals(dim, facetResult.dim); + assertEquals(aggregatedValue, facetResult.value.intValue()); + assertEquals(expected.size(), facetResult.childCount); + } } private void validateFloats( @@ -451,8 +458,15 @@ public class TestTaxonomyFacetAssociations extends FacetTestCase { } FacetResult facetResult = facets.getTopChildren(10, dim); - assertEquals(dim, facetResult.dim); - assertEquals(aggregatedValue, facetResult.value.floatValue(), 1); - assertEquals(expected.size(), facetResult.childCount); + + if (expected.isEmpty()) { + // If we hit the rare random case where nothing is indexed for the dim, we expect a null + // facetResult (see: LUCENE-10529) + assertNull(facetResult); + } else { + assertEquals(dim, facetResult.dim); + assertEquals(aggregatedValue, facetResult.value.floatValue(), 1); + assertEquals(expected.size(), facetResult.childCount); + } } }