From ea7c75cb5238f5238c1b459c54f74bf2cc6f271a Mon Sep 17 00:00:00 2001 From: Marc Zwart Date: Tue, 20 Mar 2018 15:47:34 +0100 Subject: [PATCH] move locks to try block to ensure unlocking along all execution paths --- Mage.Server/src/main/java/mage/server/ChatSession.java | 2 +- Mage.Server/src/main/java/mage/server/UserManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/ChatSession.java b/Mage.Server/src/main/java/mage/server/ChatSession.java index da9b897f7e..e73c0410f1 100644 --- a/Mage.Server/src/main/java/mage/server/ChatSession.java +++ b/Mage.Server/src/main/java/mage/server/ChatSession.java @@ -90,8 +90,8 @@ public class ChatSession { String userName = clients.get(userId); if (reason != DisconnectReason.LostConnection) { // for lost connection the user will be reconnected or session expire so no removeUserFromAllTablesAndChat of chat yet final Lock w = lock.writeLock(); - w.lock(); try { + w.lock(); clients.remove(userId); } finally { w.unlock(); diff --git a/Mage.Server/src/main/java/mage/server/UserManager.java b/Mage.Server/src/main/java/mage/server/UserManager.java index cd30111745..767f7bb59a 100644 --- a/Mage.Server/src/main/java/mage/server/UserManager.java +++ b/Mage.Server/src/main/java/mage/server/UserManager.java @@ -231,8 +231,8 @@ public enum UserManager { } logger.debug("Users to remove " + toRemove.size()); final Lock w = lock.readLock(); - w.lock(); try { + w.lock(); for (User user : toRemove) { users.remove(user.getId()); }