KEYCLOAK-4821

This commit is contained in:
Bill Burke 2017-04-29 10:41:32 -04:00
parent bbed1ffca7
commit 1f4311a02c
3 changed files with 6 additions and 13 deletions

View file

@ -478,9 +478,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
void attachSession(UserSessionAdapter userSession, ClientSessionModel clientSession) {
UserSessionEntity entity = userSession.getEntity();
String clientSessionId = clientSession.getId();
if (entity.getClientSessions() == null) {
entity.setClientSessions(new HashSet<String>());
}
if (!entity.getClientSessions().contains(clientSessionId)) {
entity.getClientSessions().add(clientSessionId);
userSession.update();
@ -513,9 +510,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
String clientSessionId = clientSession.getId();
if (entity.getClientSessions() != null && entity.getClientSessions().contains(clientSessionId)) {
entity.getClientSessions().remove(clientSessionId);
if (entity.getClientSessions().isEmpty()) {
entity.setClientSessions(null);
}
userSession.update();
}
}

View file

@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
@ -121,7 +122,7 @@ public class UserSessionAdapter implements UserSessionModel {
@Override
public void setNote(String name, String value) {
if (entity.getNotes() == null) {
entity.setNotes(new HashMap<String, String>());
entity.setNotes(new ConcurrentHashMap<>());
}
entity.getNotes().put(name, value);
update();

View file

@ -21,6 +21,8 @@ import org.keycloak.models.UserSessionModel;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
@ -44,11 +46,11 @@ public class UserSessionEntity extends SessionEntity {
private int lastSessionRefresh;
private Set<String> clientSessions;
private Set<String> clientSessions = new CopyOnWriteArraySet<>();
private UserSessionModel.State state;
private Map<String, String> notes;
private Map<String, String> notes = new ConcurrentHashMap<>();
public String getUser() {
return user;
@ -110,10 +112,6 @@ public class UserSessionEntity extends SessionEntity {
return clientSessions;
}
public void setClientSessions(Set<String> clientSessions) {
this.clientSessions = clientSessions;
}
public Map<String, String> getNotes() {
return notes;
}