Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestHighLevelClient in spring boot 2.1.x doesn't allow a spring cloud task to finish successfully #41929

Closed
VernonG07 opened this issue May 8, 2019 · 3 comments

Comments

@VernonG07
Copy link

Elasticsearch version (bin/elasticsearch --version):
Tested with 6.4.2 through 7.0.0

JVM version (java -version):

java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

OS version (uname -a if on a Unix-like system):

Description of the problem including expected versus actual behavior:
Including elasticsearch-rest-high-level-client on the classpath for a spring-boot, spring cloud task service does not properly close and therefor doesn't die after the task is complete.

Removing Elasticsearch from the classpath allows the spring cloud task to function correctly and die after the task is finished.

Steps to reproduce:

  1. Clone https://github.com/spring-cloud/spring-cloud-task/tree/master/spring-cloud-task-samples/timestamp
  2. Run the application - The service dies after it prints the timestamp
  3. Add
                <dependency>
			<groupId>org.elasticsearch.client</groupId>
			<artifactId>elasticsearch-rest-high-level-client</artifactId>
			<version>7.0.0</version>
		</dependency>
  1. Re-run the application - The service now stays alive

Notes
With:
Spring Cloud Task - Finchley.SR3
Spring Boot - 2.0.x
Rest High Level Client - 6.4.2
The app functions as intended.
With:
Spring Cloud Task - Greenwich.SR1
Spring Boot -2.1.x
Rest High Level Client - 6.4.2
The app exhibits the problematic behavior

@dadoonet
Copy link
Member

dadoonet commented May 8, 2019

When using springboot with
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.0.0<elasticsearch.version>
</properties>

See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions

Could you next time ask on discuss.elastic.co instead?

@dadoonet dadoonet closed this as completed May 8, 2019
@astefan
Copy link
Contributor

astefan commented May 8, 2019

@VernonG07 I don't think this has anything to do specifically with Elasticsearch. From what I remember, Spring (and Spring Boot) do have ways to define/configure "destroy" like behavior for each of its components (beans). And the HLRC makes no exception imo.
Have a look here for an example - Step 6.

@VernonG07
Copy link
Author

VernonG07 commented May 8, 2019

@astefan I should have mentioned that I also have a @configuration with a RestHighLevelClient @bean. I made sure to close the RestHighLevelClient as well as the LowLevelClient on task completion. Still doesn't behave as expected. It also confusing that the exact same configuration for Spring Boot 2.0.x and Spring Cloud Finchley work just fine.
@dadoonet I have followed your advice and created something on discuss.elastic.co

UPDATE: looks like it was an Elasticsearch Autoconfig issue that is now included in spring boot 2.1.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants