I have a method that initializes a Session
object (Cassandra Session, which according to best practices should be shared across application threads as it is quite expensive to initialize one) and returns it back to the caller. Sonarqube suggests closing my Session
object in finally
block or by using try-with-resources
construct.
It doesn't make sense to do it my case as a session should be closed only when the application is shutting down.
Such check makes sense only if my resource should be closed immediately after usage, like connection, file, etc.
How do I get rid of that type of error, please advise.