Hibernatesearch does not close client in case elasticsearch is unavailable

Description

Steps to reproduce

  • Add hibernate search in spring-boot 2.1

  • Set spring.jpa.properties.hibernate.search.default.elasticsearch.host=http://localhost:9200

  • Start spring boot

  • I get

Actual result

  • Spring boot application hangs and the process does not end
    Expected result

  • 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:

Environment

None
Fixed

Assignee

Valentin Aitken

Reporter

Valentin Aitken

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

Priority

Minor
Configure