diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostDataAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostDataAction.java index 2206f265a7c..28589683ffc 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostDataAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportPostDataAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManage import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.TimeRange; +import java.io.InputStream; import java.util.Optional; public class TransportPostDataAction extends TransportJobTaskAction { @@ -37,8 +38,8 @@ public class TransportPostDataAction extends TransportJobTaskAction listener) { TimeRange timeRange = TimeRange.builder().startTime(request.getResetStart()).endTime(request.getResetEnd()).build(); DataLoadParams params = new DataLoadParams(timeRange, Optional.ofNullable(request.getDataDescription())); - try { - processManager.processData(task, analysisRegistry, request.getContent().streamInput(), request.getXContentType(), + try (InputStream contentStream = request.getContent().streamInput()) { + processManager.processData(task, analysisRegistry, contentStream, request.getXContentType(), params, (dataCounts, e) -> { if (dataCounts != null) { listener.onResponse(new PostDataAction.Response(dataCounts));