Apache Lucene open-source search software
LUCENE-6446: Protected against null sub explanations.
Adrien Grand9cc27ca4205f
diff --git a/lucene/core/src/java/org/apache/lucene/search/Explanation.java b/lucene/core/src/java/org/apache/lucene/search/Explanation.javaindex cfeb6574c4a..c554861efaa 100644--- a/lucene/core/src/java/org/apache/lucene/search/Explanation.java+++ b/lucene/core/src/java/org/apache/lucene/search/Explanation.java@@ -72,6 +72,9 @@ public class Explanation {this.value = value;this.description = Objects.requireNonNull(description);this.details = Collections.unmodifiableList(new ArrayList<>(details));+ for (Explanation detail : details) {+ Objects.requireNonNull(detail);+ }}/**diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java b/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.javaindex f5fb14e1822..9d0afe13dec 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java@@ -134,8 +134,12 @@ public class BBoxOverlapRatioValueSource extends BBoxSimilarityValueSource {double top = Math.min(queryExtent.getMaxY(), target.getMaxY());double bottom = Math.max(queryExtent.getMinY(), target.getMinY());double height = top - bottom;- if (height < 0)+ if (height < 0) {+ if (exp != null) {+ exp.set(Explanation.noMatch("No intersection"));+ }return 0;//no intersection+ }// calculate "width": the intersection width between two boxes.double width = 0;@@ -153,6 +157,9 @@ public class BBoxOverlapRatioValueSource extends BBoxSimilarityValueSource {&& (Math.abs(b.getMinX()) == 180 || Math.abs(b.getMaxX()) == 180)) {width = 0;//both adjacent to dateline} else {+ if (exp != null) {+ exp.set(Explanation.noMatch("No intersection"));+ }return 0;//no intersection}} else {//both cross@@ -174,8 +181,12 @@ public class BBoxOverlapRatioValueSource extends BBoxSimilarityValueSource {if (qryEastLeft < qryEastRight)width += qryEastRight - qryEastLeft;- if (qryWestLeft > qryWestRight && qryEastLeft > qryEastRight)+ if (qryWestLeft > qryWestRight && qryEastLeft > qryEastRight) {+ if (exp != null) {+ exp.set(Explanation.noMatch("No intersection"));+ }return 0;//no intersection+ }}}