SessionRegistryImpl uses computeIfAbsent

Fixes: gh-5834
This commit is contained in:
Robbie Martinus 2018-12-04 19:58:44 +11:00 committed by Rob Winch
parent e995668d92
commit 090000c3d2
1 changed files with 1 additions and 11 deletions

View File

@ -132,17 +132,7 @@ public class SessionRegistryImpl implements SessionRegistry,
sessionIds.put(sessionId,
new SessionInformation(principal, sessionId, new Date()));
Set<String> sessionsUsedByPrincipal = principals.get(principal);
if (sessionsUsedByPrincipal == null) {
sessionsUsedByPrincipal = new CopyOnWriteArraySet<>();
Set<String> prevSessionsUsedByPrincipal = principals.putIfAbsent(principal,
sessionsUsedByPrincipal);
if (prevSessionsUsedByPrincipal != null) {
sessionsUsedByPrincipal = prevSessionsUsedByPrincipal;
}
}
Set<String> sessionsUsedByPrincipal = principals.computeIfAbsent(principal, key -> new CopyOnWriteArraySet<>());
sessionsUsedByPrincipal.add(sessionId);
if (logger.isTraceEnabled()) {