mirror of
https://github.com/correl/mage.git
synced 2024-11-16 11:09:29 +00:00
move locks to try block to ensure unlocking along all execution paths
This commit is contained in:
parent
d299ee0882
commit
ea7c75cb52
2 changed files with 2 additions and 2 deletions
|
@ -90,8 +90,8 @@ public class ChatSession {
|
||||||
String userName = clients.get(userId);
|
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
|
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();
|
final Lock w = lock.writeLock();
|
||||||
w.lock();
|
|
||||||
try {
|
try {
|
||||||
|
w.lock();
|
||||||
clients.remove(userId);
|
clients.remove(userId);
|
||||||
} finally {
|
} finally {
|
||||||
w.unlock();
|
w.unlock();
|
||||||
|
|
|
@ -231,8 +231,8 @@ public enum UserManager {
|
||||||
}
|
}
|
||||||
logger.debug("Users to remove " + toRemove.size());
|
logger.debug("Users to remove " + toRemove.size());
|
||||||
final Lock w = lock.readLock();
|
final Lock w = lock.readLock();
|
||||||
w.lock();
|
|
||||||
try {
|
try {
|
||||||
|
w.lock();
|
||||||
for (User user : toRemove) {
|
for (User user : toRemove) {
|
||||||
users.remove(user.getId());
|
users.remove(user.getId());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue