Skip to content
Snippets Groups Projects
Commit cfc38df1 authored by srosse's avatar srosse
Browse files

OO-1873: fix an issue with the ConcurrentHashMaps

parent 2965446a
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ import java.util.Comparator; ...@@ -23,6 +23,7 @@ import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -271,8 +272,9 @@ public class UserSessionManager implements GenericEventListener { ...@@ -271,8 +272,9 @@ public class UserSessionManager implements GenericEventListener {
//SIDEEFFECT!! to signOffAndClear //SIDEEFFECT!! to signOffAndClear
//if invalidatedSession is removed from authUserSessions //if invalidatedSession is removed from authUserSessions
//signOffAndClear does not remove the identity.getName().toLowerCase() from the userNameToIdentity //signOffAndClear does not remove the identity.getName().toLowerCase() from the userNameToIdentity
// if(invalidatedSession != null) {
authUserSessions.remove(invalidatedSession); authUserSessions.remove(invalidatedSession);
}
} }
authUserSessions.add(usess); authUserSessions.add(usess);
// user can choose upercase letters in identity name, but this has no effect on the // user can choose upercase letters in identity name, but this has no effect on the
...@@ -430,7 +432,7 @@ public class UserSessionManager implements GenericEventListener { ...@@ -430,7 +432,7 @@ public class UserSessionManager implements GenericEventListener {
//remove only from identityEnvironment if found in sessions. //remove only from identityEnvironment if found in sessions.
//see also SIDEEFFECT!! line in signOn(..) //see also SIDEEFFECT!! line in signOn(..)
Identity previousSignedOn = identityEnvironment.getIdentity(); Identity previousSignedOn = identityEnvironment.getIdentity();
if (previousSignedOn != null) { if (previousSignedOn != null && previousSignedOn.getKey() != null) {
if(isDebug) log.debug("signOffAndClearWithout() removing from userNameToIdentity: "+previousSignedOn.getName().toLowerCase()); if(isDebug) log.debug("signOffAndClearWithout() removing from userNameToIdentity: "+previousSignedOn.getName().toLowerCase());
userNameToIdentity.remove(previousSignedOn.getKey()); userNameToIdentity.remove(previousSignedOn.getKey());
userSessionCache.remove(previousSignedOn.getKey()); userSessionCache.remove(previousSignedOn.getKey());
...@@ -459,6 +461,7 @@ public class UserSessionManager implements GenericEventListener { ...@@ -459,6 +461,7 @@ public class UserSessionManager implements GenericEventListener {
* - WindowManager responsible to dispose controller chain * - WindowManager responsible to dispose controller chain
* @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event) * @see org.olat.core.util.event.GenericEventListener#event(org.olat.core.gui.control.Event)
*/ */
@Override
public void event(Event event) { public void event(Event event) {
if(event instanceof SignOnOffEvent) { if(event instanceof SignOnOffEvent) {
SignOnOffEvent se = (SignOnOffEvent) event; SignOnOffEvent se = (SignOnOffEvent) event;
...@@ -592,7 +595,7 @@ public class UserSessionManager implements GenericEventListener { ...@@ -592,7 +595,7 @@ public class UserSessionManager implements GenericEventListener {
UserSession identitySession = null; UserSession identitySession = null;
if(identityKey != null) { if(identityKey != null) {
//do not call from somewhere else then signOffAndClear!! //do not call from somewhere else then signOffAndClear!!
identitySession = authUserSessions.stream().filter(userSession -> { Optional<UserSession> optionalSession = authUserSessions.stream().filter(userSession -> {
Identity identity = userSession.getIdentity(); Identity identity = userSession.getIdentity();
if (identity != null && identityKey.equals(identity.getKey()) if (identity != null && identityKey.equals(identity.getKey())
&& userSession.getSessionInfo() != null && userSession.getSessionInfo() != null
...@@ -601,7 +604,9 @@ public class UserSessionManager implements GenericEventListener { ...@@ -601,7 +604,9 @@ public class UserSessionManager implements GenericEventListener {
return true; return true;
} }
return false; return false;
}).findFirst().get(); }).findFirst();
identitySession = optionalSession.isPresent() ? optionalSession.get() : null;
} }
return identitySession; return identitySession;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment