Skip to content

Commit

Permalink
[BP] Fix system info when ES throw errors (#7413)
Browse files Browse the repository at this point in the history
In the administration info page if ES connection throws an exception the page doesn't display any other info
like git version, paths, etc. This commit fix that catching the ES exception instead of letting it
escape to the method response.
  • Loading branch information
josegar74 authored and juanluisrp committed Oct 10, 2023
1 parent 0ca42bb commit 8ce60dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.lucene.search.TotalHits;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
Expand Down Expand Up @@ -504,7 +505,7 @@ public String getServerStatus() throws IOException {
// return getClient().ping(RequestOptions.DEFAULT);
}

public String getServerVersion() throws IOException {
public String getServerVersion() throws IOException, ElasticsearchException {
MainResponse.Version version = client.info(RequestOptions.DEFAULT).getVersion();

return version.getNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jeeves.server.ServiceConfig;
import jeeves.server.context.ServiceContext;
import org.apache.commons.dbcp2.BasicDataSource;
import org.elasticsearch.ElasticsearchException;
import org.fao.geonet.GeonetContext;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.kernel.search.EsSearchManager;
Expand Down Expand Up @@ -65,7 +66,7 @@ public SiteInformation(final ServiceContext context, final GeonetContext gc) {
}
try {
loadIndexInfo(context);
} catch (IOException e) {
} catch (IOException | ElasticsearchException e) {
Log.error(Geonet.GEONETWORK, e.getMessage(), e);
}
loadVersionInfo();
Expand Down

0 comments on commit 8ce60dc

Please sign in to comment.