From cba4421a753772aaedff2526c966aa01cb1cc0ed Mon Sep 17 00:00:00 2001 From: David Kyle Date: Wed, 8 Nov 2017 16:22:43 +0000 Subject: [PATCH] [ML] Fix streaming the process update request (elastic/x-pack-elasticsearch#2928) Original commit: elastic/x-pack-elasticsearch@cf76c13a2bbb77d69600f797594843d7e7855151 --- .../elasticsearch/xpack/ml/action/UpdateProcessAction.java | 2 +- .../xpack/ml/action/UpdateProcessActionRequestTests.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java index 7c480f10799..508d5193188 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/UpdateProcessAction.java @@ -142,7 +142,7 @@ public class UpdateProcessAction extends super.readFrom(in); modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new); if (in.readBoolean()) { - in.readList(JobUpdate.DetectorUpdate::new); + detectorUpdates = in.readList(JobUpdate.DetectorUpdate::new); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java index 984485a317f..60ddb1495d4 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/UpdateProcessActionRequestTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig; +import java.util.ArrayList; import java.util.List; public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase { @@ -22,9 +23,10 @@ public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase< } List updates = null; if (randomBoolean()) { + updates = new ArrayList<>(); int detectorUpdateCount = randomIntBetween(0, 5); for (int i = 0; i < detectorUpdateCount; i++) { - new JobUpdate.DetectorUpdate(randomInt(), randomAlphaOfLength(10), null); + updates.add(new JobUpdate.DetectorUpdate(randomInt(), randomAlphaOfLength(10), null)); } } return new UpdateProcessAction.Request(randomAlphaOfLength(10), config, updates);