Skip to content

Commit 4f1ad0f

Browse files
committed
Exclude *Pool classes from LockType
1 parent 97a0b9f commit 4f1ad0f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/ql/lib/semmle/code/java/Concurrency.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ import semmle.code.java.frameworks.Mockito
66

77
/**
88
* A Java type representing a lock.
9-
* We identify a lock type as one that has both `lock` and `unlock` methods.
9+
*
10+
* We exclude types with a name ending in "Pool" as they typically manage a
11+
* collection of resources and the `lock` and `unlock` methods typically only
12+
* lock one resource at a time.
1013
*/
1114
class LockType extends RefType {
1215
LockType() {
1316
this.getAMethod().hasName("lock") and
14-
this.getAMethod().hasName("unlock")
17+
this.getAMethod().hasName("unlock") and
18+
not this.getName().matches("%Pool")
1519
}
1620

1721
/** Gets a method that is locking this lock type. */

0 commit comments

Comments
 (0)