Way to change .jar return code and avoid SONAR violation "System.exit() should not be used in J2EE/JEE apps"

StackOverflow https://stackoverflow.com/questions/22459277

  •  16-06-2023
  •  | 
  •  

Question

I have a JAR which will be scripted by others and requires custom return codes. I am using System.exit(int n) atm but SONAR complains giving a "Critical" violation.

Do Not Call System Exit: System.exit() should not be used in J2EE/JEE apps.

I believe SONAR will also complain about Runtime.exit().

Is there a way to override the JAR's return code and keep SONAR happy at the same time?

Was it helpful?

Solution

You can flag any issue as "False Positive" in the sonar IDE. The offending lines of code will be ignored in later sonar runs.

Furthermore you should add a comment, which describes why you flagged this.

False Positive

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top