Skip to content

Commit

Permalink
Fix system info when ES throw errors (geonetwork#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 Oct 10, 2023
1 parent be62aec commit 4dca737
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 @@ -28,6 +28,7 @@
import jeeves.server.context.ServiceContext;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang.StringUtils;
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);
}
loadEnvInfo();
Expand Down

0 comments on commit 4dca737

Please sign in to comment.