4 rules are today using the same (shared) approach to detect synchronized blocks, and will be impacted by the change:
- S2276 (ThreadSleepCheck); FP removed when tread.sleep call is nested in a lambda:
public synchronized Consumer<Object> get() { return s -> { Thread.sleep(200); // Compliant, it was a FP! }; }
- S2273 (WaitInSynchronizeCheck): new issues:
synchronized Consumer<String> foo3() { wait(); // Compliant return s -> { wait(); // Noncompliant, new issue, the call to wait is not inside a synchronized method. }; }
- S2444 (StaticFieldInitializationCheck): New issues
static class E { static Config CONFIG; synchronized static Consumer<String> bar() { return s -> { CONFIG = null; // Noncompliant, new issue, config is updated from a non-static method }; } }
- S2696 (StaticFieldUpateCheck): No changes, the implementation of the rule check if any parent is synchronized, not the direct one!
- relates to
-
RSPEC-2273 "wait", "notify" and "notifyAll" should only be called when a lock is obviously held on an object
- Active
-
RSPEC-2276 "wait(...)" should be used instead of "Thread.sleep(...)" when a lock is held
- Active
-
RSPEC-2444 Lazy initialization of "static" fields should be "synchronized"
- Active
- links to