Search code examples
javasonarqubeignite

Sonar raises a blocker issue when I do not close ignite Object


SonarQube analysis is raising a blocker when I do not close the ignite Object. I am using the cache in a Spring Web Application, and trying to access it like this :

Ignite ignite = Ignition.getOrStart(igniteConf);

If I close the object in finally, I would not be able to reuse it again in the application without initialising and populating again, which I do not want (since the cache has the data that I want to use in the application later). Is there a way to avoid or fix the issue ?


Solution

  • I'll replicate an answer from comments here in more details.

    To make Sonar happy you can create a Spring bean corresponding to Ignite instance and autowire it in your place of use. It is effectively equivalent to using Ignition, so you can also just ignore the warning.

    Usually you don't have to worry about closing Ignite, as it follows "let-it-crash" principle.