Check session exists before saving

This commit is contained in:
Jesse Boyd 2018-07-21 15:25:27 +10:00
parent 7501eabd2e
commit 074cf281c9
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
1 changed files with 8 additions and 3 deletions

View File

@ -275,15 +275,20 @@ public class SessionManager {
*/ */
public synchronized void remove(SessionOwner owner) { public synchronized void remove(SessionOwner owner) {
checkNotNull(owner); checkNotNull(owner);
save(sessions.remove(getKey(owner))); SessionHolder session = sessions.remove(getKey(owner));
if (session != null) {
save(session);
}
} }
public synchronized void forget(SessionOwner owner) { public synchronized void forget(SessionOwner owner) {
checkNotNull(owner); checkNotNull(owner);
UUID key = getKey(owner); UUID key = getKey(owner);
SessionHolder holder = sessions.remove(key); SessionHolder holder = sessions.remove(key);
softSessions.put(key, new SoftReference(holder)); if (holder != null) {
save(holder); softSessions.put(key, new SoftReference(holder));
save(holder);
}
} }
/** /**