- SonarQube version 8.9.8 (build 54436)
- Rule: java:S2142 “InterruptedException” should not be ignored
- “Either re-interrupt this method or rethrow the “InterruptedException” that can be caught here.”
Sample java method which triggers false-positive:
private static void falsePositive()
{
try
{
//some code here
try
{
Thread.sleep(500); //Interrupted Exception might be thrown here
}
catch (InterruptedException iex) //InterruptedException is caught here
{
Thread.currentThread().interrupt();
}
//more code here
}
catch (Exception ex) //false-positive issue is reported here
{
//some code here
}
}