You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2022/04/27 03:14:38 UTC
[lucene] branch main updated: LUCENE-10529: Fix TestTaxonomyFacetAssociations NPE when randomly indexing no documents for dim
This is an automated email from the ASF dual-hosted git repository.
gsmiller pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new f11468186a0 LUCENE-10529: Fix TestTaxonomyFacetAssociations NPE when randomly indexing no documents for dim
f11468186a0 is described below
commit f11468186a04acdc357385a7cea72b79736c49b4
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Tue Apr 26 20:05:39 2022 -0700
LUCENE-10529: Fix TestTaxonomyFacetAssociations NPE when randomly indexing no documents for dim
---
lucene/CHANGES.txt | 3 +++
.../taxonomy/TestTaxonomyFacetAssociations.java | 26 +++++++++++++++++-----
2 files changed, 23 insertions(+), 6 deletions(-)
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);
+ }
}
}