FP on java S5164: ThreadLocal#remove not detected when called with containing class name

Since SonarJava 5.14, and the new rule S5164 (SONARJAVA-3131).

Reproduction code :

class FpS5164
{
  private static final ThreadLocal<String> TL = new ThreadLocal<>();

  void clean()
  {
    FpS5164.TL.remove();
  }
}

The false positive disappears by removing the class name from the remove call.

Hello @alec, thanks for the feedback and the clear reproducer.

Indeed this is a wrong behavior of the rule, I created a ticket to track this issue.

Best,
Quentin

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