Skip to content

Commit

Permalink
Original conditional statement
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanmanishd committed Mar 4, 2025
1 parent 9ac3d6c commit 57618f7
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@

public class AtlasElasticsearchQuery implements AtlasIndexQuery<AtlasJanusVertex, AtlasJanusEdge> {
private static final Logger LOG = LoggerFactory.getLogger(AtlasElasticsearchQuery.class);
private static final Set<String> NETWORK_ERROR_MESSAGES =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"Connection reset by peer",
"Network error",
"Connection refused"
)));

private AtlasJanusGraph graph;
private RestHighLevelClient esClient;
private RestClient lowLevelRestClient;
Expand Down Expand Up @@ -275,7 +270,10 @@ private DirectIndexQueryResult performAsyncDirectIndexQuery(SearchParams searchP
*/
private void handleNetworkErrors(Exception e) throws AtlasBaseException {
if (e instanceof SocketTimeoutException || e instanceof UnknownHostException ||
(e.getMessage() != null && NETWORK_ERROR_MESSAGES.stream().anyMatch(e.getMessage()::contains))) {
(e.getMessage() != null &&
(e.getMessage().contains("Connection reset by peer") ||
e.getMessage().contains("Network error") ||
e.getMessage().contains("Connection refused")))) {
throw new AtlasBaseException(AtlasErrorCode.SERVICE_UNAVAILABLE,
"Service is unavailable or a network error occurred: Elasticsearch - " + e.getMessage());
}
Expand Down

0 comments on commit 57618f7

Please sign in to comment.