Skip to content

Commit

Permalink
Merge pull request keycloak#4163 from mposolda/master
Browse files Browse the repository at this point in the history
KEYCLOAK-4939 ConcurrentLoginTest broken in latest master
  • Loading branch information
mposolda authored May 19, 2017
2 parents 4d5ca2b + e2a7b71 commit ce93207
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public void setUserSession(UserSessionModel userSession) {
}
} else {
this.userSession = (UserSessionAdapter) userSession;

if (sessionEntity.getAuthenticatedClientSessions() == null) {
sessionEntity.setAuthenticatedClientSessions(new HashMap<>());
}
sessionEntity.getAuthenticatedClientSessions().put(clientUUID, entity);
update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -518,7 +519,8 @@ public UserSessionAdapter importUserSession(UserSessionModel userSession, boolea
entity.setBrokerUserId(userSession.getBrokerUserId());
entity.setIpAddress(userSession.getIpAddress());
entity.setLoginUsername(userSession.getLoginUsername());
entity.setNotes(userSession.getNotes());
entity.setNotes(userSession.getNotes()== null ? new ConcurrentHashMap<>() : userSession.getNotes());
entity.setAuthenticatedClientSessions(new ConcurrentHashMap<>());
entity.setRememberMe(userSession.isRememberMe());
entity.setState(userSession.getState());
entity.setUser(userSession.getUser().getId());
Expand Down Expand Up @@ -555,10 +557,6 @@ private AuthenticatedClientSessionAdapter importClientSession(UserSessionAdapter
entity.setTimestamp(clientSession.getTimestamp());

Map<String, AuthenticatedClientSessionEntity> clientSessions = importedUserSession.getEntity().getAuthenticatedClientSessions();
if (clientSessions == null) {
clientSessions = new HashMap<>();
importedUserSession.getEntity().setAuthenticatedClientSessions(clientSessions);
}

clientSessions.put(clientSession.getClient().getId(), entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ public String getNote(String name) {

@Override
public void setNote(String name, String value) {
if (entity.getNotes() == null) {
entity.setNotes(new ConcurrentHashMap<>());
}
if (value == null) {
if (entity.getNotes().containsKey(name)) {
removeNote(name);
Expand Down Expand Up @@ -201,8 +198,8 @@ public void restartSession(RealmModel realm, UserModel user, String loginUsernam
provider.updateSessionEntity(entity, realm, user, loginUsername, ipAddress, authMethod, rememberMe, brokerSessionId, brokerUserId);

entity.setState(null);
entity.setNotes(null);
entity.setAuthenticatedClientSessions(null);
entity.getNotes().clear();
entity.getAuthenticatedClientSessions().clear();

update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class UserSessionEntity extends SessionEntity {

private Map<String, String> notes = new ConcurrentHashMap<>();

private Map<String, AuthenticatedClientSessionEntity> authenticatedClientSessions;
private Map<String, AuthenticatedClientSessionEntity> authenticatedClientSessions = new ConcurrentHashMap<>();

public String getUser() {
return user;
Expand Down

0 comments on commit ce93207

Please sign in to comment.