From cda89ffd407be450c367750b20f7f28146dff6cb Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Thu, 28 Sep 2023 10:49:20 -0700 Subject: [PATCH] fix null exception in text docs data set (#1403) Signed-off-by: Yaliang Wu --- .../common/dataset/TextDocsInputDataSet.java | 12 ++++- .../dataset/TextDocsInputDataSetTest.java | 53 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 common/src/test/java/org/opensearch/ml/common/dataset/TextDocsInputDataSetTest.java diff --git a/common/src/main/java/org/opensearch/ml/common/dataset/TextDocsInputDataSet.java b/common/src/main/java/org/opensearch/ml/common/dataset/TextDocsInputDataSet.java index 93a26f649c..98672841d7 100644 --- a/common/src/main/java/org/opensearch/ml/common/dataset/TextDocsInputDataSet.java +++ b/common/src/main/java/org/opensearch/ml/common/dataset/TextDocsInputDataSet.java @@ -15,6 +15,7 @@ import org.opensearch.ml.common.output.model.ModelResultFilter; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -40,7 +41,11 @@ public TextDocsInputDataSet(List docs, ModelResultFilter resultFilter) { public TextDocsInputDataSet(StreamInput streamInput) throws IOException { super(MLInputDataType.TEXT_DOCS); - docs = streamInput.readStringList(); + docs = new ArrayList<>(); + int size = streamInput.readInt(); + for (int i=0; i