diff --git a/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java b/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java index 9d2076488..af648c106 100644 --- a/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java +++ b/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java @@ -77,7 +77,6 @@ import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; import org.opensearch.timeseries.common.exception.EndRunException; -import org.opensearch.timeseries.common.exception.ResourceNotFoundException; import org.opensearch.timeseries.common.exception.TimeSeriesException; import org.opensearch.timeseries.constant.CommonMessages; import org.opensearch.timeseries.constant.CommonName; @@ -747,7 +746,7 @@ private void updateMappingIfNecessary(GroupedActionListener delegateListen private void updateCustomResultIndexMapping(IndexType customIndex, GroupedActionListener delegateListeneer) { getConfigsWithCustomResultIndexAlias(ActionListener.wrap(candidateResultAliases -> { - if (candidateResultAliases.size() == 0) { + if (candidateResultAliases == null || candidateResultAliases.size() == 0) { logger.info("candidate custom result indices are empty."); markMappingUpdated(customIndex); delegateListeneer.onResponse(null); @@ -784,7 +783,7 @@ private void getConfigsWithCustomResultIndexAlias(ActionListener> l } } if (configIndex == null || configIndex.getIndexName() == null) { - listener.onFailure(new ResourceNotFoundException("fail to find config index")); + listener.onResponse(new ArrayList()); return; } BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); @@ -800,7 +799,7 @@ private void getConfigsWithCustomResultIndexAlias(ActionListener> l client.search(searchRequest, ActionListener.wrap(r -> { if (r == null || r.getHits().getTotalHits() == null || r.getHits().getTotalHits().value == 0) { logger.info("no config available."); - listener.onResponse(null); + listener.onResponse(new ArrayList()); return; } Iterator iterator = r.getHits().iterator();