You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/04/21 18:39:02 UTC

svn commit: r1675153 - in /lucene/dev/trunk: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/search/Explanation.java lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java

Author: jpountz
Date: Tue Apr 21 16:39:02 2015
New Revision: 1675153

URL: http://svn.apache.org/r1675153
Log:
LUCENE-6446: Protected against null sub explanations.

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/core/   (props changed)
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Explanation.java
    lucene/dev/trunk/lucene/spatial/   (props changed)
    lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Explanation.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Explanation.java?rev=1675153&r1=1675152&r2=1675153&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Explanation.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/Explanation.java Tue Apr 21 16:39:02 2015
@@ -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);
+    }
   }
 
   /**

Modified: lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java?rev=1675153&r1=1675152&r2=1675153&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java (original)
+++ lucene/dev/trunk/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxOverlapRatioValueSource.java Tue Apr 21 16:39:02 2015
@@ -134,8 +134,12 @@ public class BBoxOverlapRatioValueSource
     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
               && (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
         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
+        }
       }
     }