JD.UMC.WAIT

JD.UMC.WAIT occurs when a method calls wait() on a java.util.concurrent.locks.Condition object.

Vulnerability and risk

This code will not achieve the intended results.

Mitigation and prevention

Waiting for a Condition should be done with one of the await() methods defined by the Condition interface.

Example 1

11     void waitForCondition(Condition cond) {
12         try {
13             cond.wait();
14         } catch (InterruptedException e) {
15             return;
16         }
17     }
18     // corrected code
19     void waitForCondition2(Condition cond) {
20         try {
21             cond.await();
22         } catch (InterruptedException e) {
23             return;
24         }
25     }

JD.UMC.WAIT is reported for call on line 13: There is a call to method 'cond.wait()'. Should use method 'cond.await()' instead.