SonarQube version 7.6
Java 1.8
When we use Spring Data ElasticSearch in Spring framework,The lifecycle of a Spring Bean is usually managed by the Spring IOC container。
But sonarQube raise a blocker bug saying “Use try-with-resources or close this “ElasticsearchRestClient” in a “finally” clause.”
Ideally this is not a bug, but due to this false analysis, our project rating is showing E.
Below is the code:
This usage comes from:
https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.operations.resttemplate