mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-12 21:33:30 +00:00
SEC-543: Added null guard clauses to reduce nesting and increase readability.
This commit is contained in:
parent
c9de2f6c9f
commit
9fe181046b
@ -145,31 +145,36 @@ public class SessionRegistryImpl implements SessionRegistry, ApplicationListener
|
|||||||
|
|
||||||
SessionInformation info = getSessionInformation(sessionId);
|
SessionInformation info = getSessionInformation(sessionId);
|
||||||
|
|
||||||
if (info != null) {
|
if (info == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Removing session " + sessionId + " from set of registered sessions");
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionIds.remove(sessionId);
|
||||||
|
|
||||||
|
Set sessionsUsedByPrincipal = (Set) principals.get(info.getPrincipal());
|
||||||
|
|
||||||
|
if (sessionsUsedByPrincipal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (sessionsUsedByPrincipal) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Removing session " + sessionId + " from set of registered sessions");
|
logger.debug("Removing session " + sessionId + " from principal's set of registered sessions");
|
||||||
}
|
}
|
||||||
sessionIds.remove(sessionId);
|
|
||||||
|
|
||||||
Set sessionsUsedByPrincipal = (Set) principals.get(info.getPrincipal());
|
sessionsUsedByPrincipal.remove(sessionId);
|
||||||
|
|
||||||
if (sessionsUsedByPrincipal != null) {
|
if (sessionsUsedByPrincipal.size() == 0) {
|
||||||
synchronized (sessionsUsedByPrincipal) {
|
// No need to keep object in principals Map anymore
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Removing session " + sessionId + " from principal's set of registered sessions");
|
logger.debug("Removing principal " + info.getPrincipal() + " from registry");
|
||||||
}
|
}
|
||||||
|
principals.remove(info.getPrincipal());
|
||||||
sessionsUsedByPrincipal.remove(sessionId);
|
}
|
||||||
|
}
|
||||||
if (sessionsUsedByPrincipal.size() == 0) {
|
|
||||||
// No need to keep object in principals Map anymore
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Removing principal " + info.getPrincipal() + " from registry");
|
|
||||||
}
|
|
||||||
principals.remove(info.getPrincipal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user