Files
codeql/java/ql/src/Likely Bugs/Concurrency/PriorityCalls.ql
2018-10-11 11:31:37 +02:00

30 lines
859 B
Plaintext

/**
* @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."