Skip to content

Commit

Permalink
set blank response when indexNotFound exception (opensearch-project#1125
Browse files Browse the repository at this point in the history
) (opensearch-project#1126)

(cherry picked from commit 65c1519)

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent c0de31a commit 551aa0f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.TermsQueryBuilder;
Expand Down Expand Up @@ -188,7 +189,11 @@ public void getCorrelationAlerts(String ruleId, Table tableProp, ActionListener<
},
e -> {
log.error("Search request to fetch correlation alerts failed", e);
listener.onFailure(e);
if (e instanceof IndexNotFoundException) {
listener.onResponse(new GetCorrelationAlertsResponse(Collections.emptyList(), 0));
} else {
listener.onFailure(e);
}
}
));
}
Expand Down

0 comments on commit 551aa0f

Please sign in to comment.