Skip to content

Commit

Permalink
fix(elasticsearch): Connector must retry to connect to Elasticsearch …
Browse files Browse the repository at this point in the history
…when receiving bad info (backport #4919)

Closes gravitee-io/issues#4977
  • Loading branch information
brasseld authored and leleueri committed Feb 2, 2021
1 parent 0bb743d commit 3335cfe
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -226,7 +226,14 @@ private Single<ElasticsearchInfo> getInfo(final ElasticsearchClient client) thro
.get(URL_ROOT)
.rxSend()
.doOnError(throwable -> logger.error("Unable to get a connection to Elasticsearch: {}", throwable.getMessage()))
.map(response -> mapper.readValue(response.bodyAsString(), ElasticsearchInfo.class));
.map(response -> {
if (response.statusCode() == HttpStatusCode.OK_200) {
return mapper.readValue(response.bodyAsString(), ElasticsearchInfo.class);
}

throw new ElasticsearchException("Unable to retrieve Elasticsearch information: status[" +
response.statusCode()+"] payload: [" + response.bodyAsString() + "]");
});
}

@Override
Expand Down

0 comments on commit 3335cfe

Please sign in to comment.