JD.LOCK.NOTIFYJD.LOCK.NOTIFY occurs when the code calls notify() or notifyAll() while two locks are held. Vulnerability and riskThe code calls notify() or notifyAll() while two locks are held. If this notification is intended to wake up a wait() that is holding the same locks, it may deadlock, since the wait will only give up one lock and the notify will be unable to get both locks, and thus the notify will not succeed. If there is also a warning about a two-lock wait, the probability of a problem is quite high. Mitigation and preventionPreferably call a notify() method without locks held. Example 19 synchronized void finish(Object o) { 10 synchronized(o) { 11 o.notify(); 12 } 13 } JD.LOCK.NOTIFY is reported for line 11: Calling 'java.lang.Object.notify()' with two or more locks held '[this, o]' could cause a deadlock. Security guidelinesRelated checkers |