From 090000c3d288e7092c439eaaecf704c45f3a8910 Mon Sep 17 00:00:00 2001 From: Robbie Martinus <12573669+rmartinus@users.noreply.github.com> Date: Tue, 4 Dec 2018 19:58:44 +1100 Subject: [PATCH] SessionRegistryImpl uses computeIfAbsent Fixes: gh-5834 --- .../security/core/session/SessionRegistryImpl.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java b/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java index 285c6c6747..ec2a015fbd 100644 --- a/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java +++ b/core/src/main/java/org/springframework/security/core/session/SessionRegistryImpl.java @@ -132,17 +132,7 @@ public class SessionRegistryImpl implements SessionRegistry, sessionIds.put(sessionId, new SessionInformation(principal, sessionId, new Date())); - Set sessionsUsedByPrincipal = principals.get(principal); - - if (sessionsUsedByPrincipal == null) { - sessionsUsedByPrincipal = new CopyOnWriteArraySet<>(); - Set prevSessionsUsedByPrincipal = principals.putIfAbsent(principal, - sessionsUsedByPrincipal); - if (prevSessionsUsedByPrincipal != null) { - sessionsUsedByPrincipal = prevSessionsUsedByPrincipal; - } - } - + Set sessionsUsedByPrincipal = principals.computeIfAbsent(principal, key -> new CopyOnWriteArraySet<>()); sessionsUsedByPrincipal.add(sessionId); if (logger.isTraceEnabled()) {