Skip to content

Apache Lucene open-source search software

LUCENE-7185: handle underflow

Robert Muircc099d8fc60a
diff --git a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
index eb48a8fd89d..98e296684ac 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/geo/GeoTestUtil.java
@@ -195,6 +195,10 @@ public class GeoTestUtil {
} else {
double x = nextLongitudeBetween(minX, maxX);
double y = (y1 - y2) / (x1 - x2) * (x-x1) + y1;
+ if (Double.isFinite(y) == false) {
+ // this can happen due to underflow when delta between x values is wonderfully tiny!
+ y = Math.copySign(90, x1);
+ }
double delta = (maxY - minY) * 0.01;
// our formula may put the targeted Y out of bounds
y = Math.min(90, y);