rule: Condition.wait() methods not called inside a loop
Brought to you by:
chrismair
We have a rule to ensure that the Object.wait() method is only called within a while loop (WaitOutsideOfWhileLoop).
The java.util.concurrent.locks.Condition has a similar “requirement” about its await() methods (see the class javadoc).
I assume this would include all of the awaitXX() methods on Condition: await(), awaitNanos(), awaitUninterruptibly() and awaitUntil().
NOTE: If you see a call to wait(), there is no ambiguity about it being the wrong wait() method, since it is defined on Object. But the await() methods could catch unintended method invocations (false positives) on objects other than Locks.
Something to consider when we implement this rule.
We need to be very careful implementing this rule to make sure that *only* await() on Condition objects are caught. We need a better type-inference system in general before tackling this rule.