Hibernatesearch does not close client in case elasticsearch is unavailable
Steps to reproduce
Add hibernate search in spring-boot 2.1
Start spring boot
Spring boot application hangs and the process does not end
Spring boot application must exit with an error code
Why it happens?
DefaultElasticsearchService first builds a clientImplementor which is starting an ExecutorService inside restClient.
Then after that createDialect is called which uses clientImplementor to check version of elasticsearch. When version check fails exception is thrown and clientImplementor is leftover and not closed.
Suggestion is this.client to obtain a reference before its first usage (or immidiatelly after initializatin) so in case clientImplementor fails, stop() takes care of it.
See the stack bellow: