Java client hangs

Hello!

I am writing a Java program to work with Elasticsearch server.
My Java client version is 7.17.4, server version is 7.17.0.
Consider the following code:

RestClient restClient = RestClient.builder(new HttpHost("host.org", 9200, "https")).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchIndicesClient indicesClient = new ElasticsearchIndicesClient(transport);
indicesClient.delete(b -> b.index("non-existent-index"));

I see the following exception on console (pretty valid):

Exception in thread "main" co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/indices.delete] failed: [index_not_found_exception] no such index [non-existent-index]
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:281)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.delete(ElasticsearchIndicesClient.java:382)
	at co.elastic.clients.elasticsearch.indices.ElasticsearchIndicesClient.delete(ElasticsearchIndicesClient.java:398)

but the program hungs forever.

Why?

Thanks in advance.

You have to call transport.close(): the http client internally contains a pool of open connections and associated threads.

Indeed, thanks a lot!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.