-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathCallsToConditionWait.ql
More file actions
33 lines (29 loc) · 965 Bytes
/
CallsToConditionWait.ql
File metadata and controls
33 lines (29 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @name Wait on condition
* @description Calling 'wait' on a 'Condition' interface may result in unexpected behavior and is
* probably a typographical error.
* @kind problem
* @problem.severity error
* @precision medium
* @id java/wait-on-condition-interface
* @tags reliability
* correctness
* concurrency
* external/cwe/cwe-662
*/
import java
class WaitMethod extends Method {
WaitMethod() {
this.hasName("wait") and
this.hasNoParameters() and
this.getDeclaringType().hasQualifiedName("java.lang", "Object")
}
}
class ConditionInterface extends Interface {
ConditionInterface() { this.hasQualifiedName("java.util.concurrent.locks", "Condition") }
}
from MethodCall ma, ConditionInterface condition
where
ma.getMethod() instanceof WaitMethod and
ma.getQualifier().getType().(RefType).hasSupertype*(condition)
select ma, "Waiting for a condition should use Condition.await, not Object.wait."