From 70871b5af789f6f4b499122bc302744f32588c29 Mon Sep 17 00:00:00 2001 From: Christophe Bismuth Date: Thu, 25 Oct 2018 18:12:50 +0200 Subject: [PATCH] Check self references in metric agg after last doc collection (#33593) (#34001) * Check self references in metric agg after last doc collection (#33593) * Revert 0aff5a30c5dbad9f476be14f34b81e2d1991bb0f (#33593) * Check self refs in metric agg only once in post collection hook (#33593) * Remove unnecessary mocking (#33593) --- .../aggregations/metrics/ScriptedMetricAggregator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java index 345b21d03887e..da936a76ee1ca 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java @@ -80,7 +80,6 @@ public void collect(int doc, long bucket) throws IOException { leafMapScript.setDocument(doc); leafMapScript.execute(); - CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script"); } }; } @@ -103,4 +102,10 @@ public InternalAggregation buildEmptyAggregation() { return new InternalScriptedMetric(name, null, reduceScript, pipelineAggregators(), metaData()); } + @Override + protected void doPostCollection() throws IOException { + CollectionUtils.ensureNoSelfReferences(aggState, "Scripted metric aggs map script"); + + super.doPostCollection(); + } }