From cc099d8fc60a7693417754f9b3a3f51f0952f9a3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 18 Apr 2016 09:15:04 -0400 Subject: [PATCH] LUCENE-7185: handle underflow --- .../src/java/org/apache/lucene/geo/GeoTestUtil.java | 4 ++++ 1 file changed, 4 insertions(+) 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);