diff --git a/src/main/java/org/gcube/socialnetworking/social_data_search_client/ElasticSearchClientImpl.java b/src/main/java/org/gcube/socialnetworking/social_data_search_client/ElasticSearchClientImpl.java index 6126d93..d65c06e 100644 --- a/src/main/java/org/gcube/socialnetworking/social_data_search_client/ElasticSearchClientImpl.java +++ b/src/main/java/org/gcube/socialnetworking/social_data_search_client/ElasticSearchClientImpl.java @@ -181,12 +181,13 @@ public class ElasticSearchClientImpl implements ElasticSearchClientInterface{ return response.isFound(); } - + @Override protected void finalize() throws Throwable { super.finalize(); _log.info("Called finalize.. closing connection to elasticsearch"); - client.close(); + if(client != null) + client.close(); } - + }