False positive on S2142 when Thread.currentThread().interrupt(); is called

  • SonarQube 8.9.1 + maven sonar plugin
package com.example;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class ExampleInterrupt {

  private static final BlockingQueue<Delayed> queue = new DelayQueue<>();

  public void doSomething() {
    try {
      queue.poll(1, TimeUnit.SECONDS);
    } catch (InterruptedException e) {

Sonar raises S2142 rule violation also if Thread.currentThread().interrupt(); is called in the catch block.

Hello @michele.lorenzini

After having a look at your second thread (False positive on S1206), I definitely suspect that there is something strange with the configuration of your project, I invite you to have a look at the other thread first to investigate further, as solving it will most probably solve this one at the same time.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.