From 1ad1091a17347285d68a27492ee0fdcce3a17699 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 16:32:11 -0700 Subject: [PATCH] fix failed ut from PR 1472 (#1479) (#1510) * fix failed ut from PR 1472 Signed-off-by: Yaliang Wu * exclude class for low coverage Signed-off-by: Yaliang Wu --------- Signed-off-by: Yaliang Wu (cherry picked from commit da5d82942385c34544016cf361b517c2bb3d36c4) Co-authored-by: Yaliang Wu --- plugin/build.gradle | 1 + .../java/org/opensearch/ml/model/MLModelCacheHelper.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/build.gradle b/plugin/build.gradle index b389360e0b..b8a4d47d22 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -272,6 +272,7 @@ List jacocoExclusions = [ 'org.opensearch.ml.action.deploy.TransportDeployModelAction', 'org.opensearch.ml.action.deploy.TransportDeployModelOnNodeAction', 'org.opensearch.ml.action.prediction.TransportPredictionTaskAction', + 'org.opensearch.ml.action.prediction.TransportPredictionTaskAction.1', 'org.opensearch.ml.action.tasks.GetTaskTransportAction', 'org.opensearch.ml.action.tasks.SearchTaskTransportAction', 'org.opensearch.ml.model.MLModelManager', diff --git a/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java b/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java index 680524324d..554065ed95 100644 --- a/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java +++ b/plugin/src/main/java/org/opensearch/ml/model/MLModelCacheHelper.java @@ -436,7 +436,10 @@ public void setModelInfo(String modelId, MLModel mlModel) { } public MLModel getModelInfo(String modelId) { - MLModelCache mlModelCache = getExistingModelCache(modelId); + MLModelCache mlModelCache = modelCaches.get(modelId); + if (mlModelCache == null) { + return null; + } return mlModelCache.getCachedModelInfo(); }