LockHolder: reset lock instances to null after unlocking
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Apr 2019 19:32:24 +0000 (22:32 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Apr 2019 19:34:36 +0000 (22:34 +0300)
app/src/main/java/net/ktnx/mobileledger/utils/LockHolder.java

index 0f3fa38..5890f0a 100644 (file)
@@ -31,8 +31,8 @@ public class LockHolder implements AutoCloseable {
     }
     @Override
     public void close() {
-        if (wLock != null) wLock.unlock();
-        if (rLock != null) rLock.unlock();
+        if (wLock != null) { wLock.unlock(); wLock = null; }
+        if (rLock != null) { rLock.unlock(); rLock = null; }
     }
     public void downgrade() {
         if (rLock == null) throw new IllegalStateException("no locks are held");