-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathPriorityCalls.ql
More file actions
29 lines (25 loc) · 859 Bytes
/
PriorityCalls.ql
File metadata and controls
29 lines (25 loc) · 859 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
/**
* @name Explicit thread priority
* @description Setting thread priorities to control interactions between threads is not portable,
* and may not have the desired effect.
* @kind problem
* @problem.severity warning
* @precision low
* @id java/thread-priority
* @tags portability
* correctness
* concurrency
*/
import java
class PriorityMethod extends Method {
PriorityMethod() {
(this.getName() = "setPriority" or this.getName() = "getPriority") and
this.getDeclaringType().hasQualifiedName("java.lang", "Thread")
}
}
class PriorityMethodAccess extends MethodAccess {
PriorityMethodAccess() { this.getMethod() instanceof PriorityMethod }
}
from PriorityMethodAccess ma
where ma.getCompilationUnit().fromSource()
select ma, "Avoid using thread priorities. The effect is unpredictable and not portable."