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:17:42 UTC
[lucene] branch branch_9x 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 branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 8af5ba02de1 LUCENE-10529: Fix TestTaxonomyFacetAssociations NPE when randomly indexing no documents for dim
8af5ba02de1 is described below
commit 8af5ba02de1f26249ab5e1c677552e62b09c2ad5
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 dbfe94749d1..0231f5fd815 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -90,6 +90,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 1cf52396848..21f57a784ce 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
@@ -451,9 +451,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(
@@ -475,8 +482,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);
+ }
}
}