wait or notify is called on a lock Condition, where await or signal was meant
What it finds
condition.wait() on a java.util.concurrent.locks.Condition calls the wait every object inherits, not the condition's own await: it needs the object's monitor, which the code holding the Lock does not have, and throws IllegalMonitorStateException. Likewise notify and notifyAll are meant to be signal and signalAll.
From the rule's source, monitor_call_on_condition.rs.
import java.util.concurrent.locks.Condition;import java.util.concurrent.locks.ReentrantLock; class Gate { private final ReentrantLock lock = new ReentrantLock(); private final Condition open = lock.newCondition(); void pass() throws InterruptedException { lock.lock(); try { open.wait();tx0 reports: open.wait uses the object's monitor, not the condition open.await(); open.notifyAll();tx0 reports: open.notifyAll uses the object's monitor } finally { lock.unlock(); } }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:monitor-call-on-condition" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:monitor-call-on-condition] reason="..."tx0 explain tx0/java:monitor-call-on-condition shows the same in the terminal. Found a false positive? Report it.