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

Copy
     void waitForCondition(Condition cond) {
         try {
             cond.wait();
         } catch (InterruptedException e) {
             return;
         }
     }
     // corrected code
     void waitForCondition2(Condition cond) {
         try {
             cond.await();
         } catch (InterruptedException e) {
             return;
         }
     }

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