diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/SumAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/SumAggregator.java index eca28396e3274..c8b364c08bec5 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/SumAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/SumAggregator.java @@ -83,9 +83,9 @@ public void collect(int doc, long bucket) throws IOException { value = v + value; } - var compensations = SumAggregator.this.compensations; - double delta = compensations.get(bucket); if (Double.isFinite(value)) { + var compensations = SumAggregator.this.compensations; + double delta = compensations.get(bucket); double correctedSum = v + delta; double updatedValue = value + correctedSum; delta = correctedSum - (updatedValue - value);