I have blocker issue "Close this "ConfigurableApplicationContext"" in main method
public static void main(String[] args)
{
SpringApplication.run(MyApplication.class, args);
}
I've tried code from SonarQube example
public static void main(String[] args)
{
ConfigurableApplicationContext context = null;
try
{
context = SpringApplication.run(MyApplication.class, args);
}
finally
{
if (context != null) {
context.close();
}
}
}
but it closes the context right after starting.
How to fix this issue?
The issue that SonarQube is reporting is a false positive and should be ignored. SonarQube's FAQ lists some options for removing false positives:
False-Positive and Won't Fix
You can mark individual issues as False Positive or Won't Fix through the issues interface. However, this solution doesn't work across branches - you'll have to re-mark the issue False Positive for each branch under analysis. So an in-code approach may be preferable if multiple branches of a project are under analysis:
//NOSONAR
You can use the mechanism embedded in rules engine (//NOPMD...) or the generic mechanism implemented in SonarQube: put //NOSONAR at the end of the line of the issue. This will suppress the issue.
Switch Off Issues
You can review an issue to flag it as false positive directly from the user interface.