From d536854879c5d427c1e0cf1fd74c99733c3b5d26 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 7 Jul 2020 13:55:24 -0400 Subject: [PATCH] Fix test bug in auto_date_histo The test would try to prepare a `Rounding` even when there aren't any buckets. This would fail because there is no range over which to prepare the rounding. It turns out that we don't need the rounding in that case so we just use `null` then. Closes #59131 --- .../bucket/histogram/InternalAutoDateHistogramTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalAutoDateHistogramTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalAutoDateHistogramTests.java index f487b783ae1..729ff5368da 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalAutoDateHistogramTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalAutoDateHistogramTests.java @@ -155,7 +155,7 @@ public class InternalAutoDateHistogramTests extends InternalMultiBucketAggregati int roundingIndex = reduced.getBucketInfo().roundingIdx; RoundingInfo roundingInfo = AutoDateHistogramAggregationBuilder.buildRoundings(null, null)[roundingIndex]; - Rounding.Prepared prepared = roundingInfo.rounding.prepare(lowest, highest); + Rounding.Prepared prepared = totalBucketConut > 0 ? roundingInfo.rounding.prepare(lowest, highest) : null; long normalizedDuration = (highest - lowest) / roundingInfo.getRoughEstimateDurationMillis(); int innerIntervalIndex = 0;