diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 8f660a33b..8c3f29b9d 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -55,9 +55,8 @@ module TransferFunctions (CFG : ProcCfg.S) = struct | Typ.Procname.Java java_pname -> begin match Typ.Procname.java_get_class_name java_pname, Typ.Procname.java_get_method java_pname with - | "java.util.concurrent.locks.Lock", "lock" -> - Lock - | ("java.util.concurrent.locks.ReentrantLock" + | ("java.util.concurrent.locks.Lock" + | "java.util.concurrent.locks.ReentrantLock" | "java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock" | "java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock"), ("lock" | "tryLock" | "lockInterruptibly") -> diff --git a/infer/tests/codetoanalyze/java/threadsafety/Locks.java b/infer/tests/codetoanalyze/java/threadsafety/Locks.java index 9d4bddad5..74128472c 100644 --- a/infer/tests/codetoanalyze/java/threadsafety/Locks.java +++ b/infer/tests/codetoanalyze/java/threadsafety/Locks.java @@ -76,6 +76,13 @@ public class Locks { mReentrantLock.unlock(); } + public void normalLockTryLockOk() { + if (mLock.tryLock()) { + f = 42; + mLock.unlock(); + } + } + public void rReentrantLockTryLockOk() { if (mReentrantLock.tryLock()) { f = 42; @@ -83,6 +90,7 @@ public class Locks { } } + public void reentrantLockInterruptiblyOk() throws InterruptedException { mReentrantLock.lockInterruptibly(); f = 42;