From 5f68eb945626d6fb25d7fb23ee16f255aa23a9f2 Mon Sep 17 00:00:00 2001 From: Steve Rowe Date: Mon, 11 Sep 2017 10:08:01 -0400 Subject: [PATCH] SOLR-11345: restrict double field values used for function queries to float range --- .../src/test/org/apache/solr/schema/TestPointFields.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java index 5d2adb4b289..703ddd884b5 100644 --- a/solr/core/src/test/org/apache/solr/schema/TestPointFields.java +++ b/solr/core/src/test/org/apache/solr/schema/TestPointFields.java @@ -3330,7 +3330,14 @@ public class TestPointFields extends SolrTestCaseJ4 { private void doTestDoublePointFunctionQuery(String field) throws Exception { assertTrue(h.getCore().getLatestSchema().getField(field).getType() instanceof PointField); int numVals = 10 * RANDOM_MULTIPLIER; - List values = getRandomDoubles(numVals, false); + // Restrict values to float range; otherwise conversion to float will cause truncation -> undefined results + List values = getRandomList(10, false, () -> { + Float f = Float.NaN; + while (f.isNaN()) { + f = Float.intBitsToFloat(random().nextInt()); + } + return f.doubleValue(); + }); String assertNumFound = "//*[@numFound='" + numVals + "']"; String[] idAscXpathChecks = new String[numVals + 1]; String[] idAscNegXpathChecks = new String[numVals + 1];