]> git.ktnx.net Git - mobile-ledger.git/commitdiff
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 0f3fa3886a94f23677b36aa8c52cd979d1840dff..5890f0a89a75b5946afee89a0df98587ac68a44f 100644 (file)
@@ -31,8 +31,8 @@ public class LockHolder implements AutoCloseable {
     }
     @Override
     public void close() {
     }
     @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");
     }
     public void downgrade() {
         if (rLock == null) throw new IllegalStateException("no locks are held");