mirror of https://github.com/apache/lucene.git
LUCENE-6446: Protected against null sub explanations.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1675153 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
77b74fc623
commit
9cc27ca420
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue