Skip to content

Commit

Permalink
set blank response when indexNotFound exception
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn committed Jul 2, 2024
1 parent e8d7879 commit 5666522
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 5666522

Please sign in to comment.