False-Positive: java:S2142 "InterruptedException" should not be ignored

  • 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
      }
   }

Hey there

Are you sure this is the version of SonarQube and not something like a specific SonarLint plugin? Where are you getting this version number from?

Sorry, you are right. It was the wrong number. The SonarQube version is 8.9.8 (build 54436). I’ll correct it.