Merge pull request #1767 from mposolda/master
KEYCLOAK-1999 KC server doesn't start on EAP 6.4 in local mode on Pos…
This commit is contained in:
commit
fa6b99eaab
3 changed files with 29 additions and 21 deletions
|
@ -188,32 +188,32 @@ public class JpaUserSessionPersisterProvider implements UserSessionPersisterProv
|
|||
userSessionIds.add(entity.getUserSessionId());
|
||||
}
|
||||
|
||||
TypedQuery<PersistentClientSessionEntity> query2 = em.createNamedQuery("findClientSessionsByUserSessions", PersistentClientSessionEntity.class);
|
||||
query2.setParameter("userSessionIds", userSessionIds);
|
||||
query2.setParameter("offline", offlineStr);
|
||||
List<PersistentClientSessionEntity> clientSessions = query2.getResultList();
|
||||
if (!userSessionIds.isEmpty()) {
|
||||
TypedQuery<PersistentClientSessionEntity> query2 = em.createNamedQuery("findClientSessionsByUserSessions", PersistentClientSessionEntity.class);
|
||||
query2.setParameter("userSessionIds", userSessionIds);
|
||||
query2.setParameter("offline", offlineStr);
|
||||
List<PersistentClientSessionEntity> clientSessions = query2.getResultList();
|
||||
|
||||
// Assume both userSessions and clientSessions ordered by userSessionId
|
||||
int j=0;
|
||||
for (UserSessionModel ss : result) {
|
||||
PersistentUserSessionAdapter userSession = (PersistentUserSessionAdapter) ss;
|
||||
List<ClientSessionModel> currentClientSessions = userSession.getClientSessions(); // This is empty now and we want to fill it
|
||||
// Assume both userSessions and clientSessions ordered by userSessionId
|
||||
int j = 0;
|
||||
for (UserSessionModel ss : result) {
|
||||
PersistentUserSessionAdapter userSession = (PersistentUserSessionAdapter) ss;
|
||||
List<ClientSessionModel> currentClientSessions = userSession.getClientSessions(); // This is empty now and we want to fill it
|
||||
|
||||
boolean next = true;
|
||||
while (next && j<clientSessions.size()) {
|
||||
PersistentClientSessionEntity clientSession = clientSessions.get(j);
|
||||
if (clientSession.getUserSessionId().equals(userSession.getId())) {
|
||||
PersistentClientSessionAdapter clientSessAdapter = toAdapter(userSession.getRealm(), userSession, clientSession);
|
||||
currentClientSessions.add(clientSessAdapter);
|
||||
j++;
|
||||
} else {
|
||||
next = false;
|
||||
boolean next = true;
|
||||
while (next && j < clientSessions.size()) {
|
||||
PersistentClientSessionEntity clientSession = clientSessions.get(j);
|
||||
if (clientSession.getUserSessionId().equals(userSession.getId())) {
|
||||
PersistentClientSessionAdapter clientSessAdapter = toAdapter(userSession.getRealm(), userSession, clientSession);
|
||||
currentClientSessions.add(clientSessAdapter);
|
||||
j++;
|
||||
} else {
|
||||
next = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SimpleUserSessionInitializer {
|
|||
public void run(KeycloakSession session) {
|
||||
int count = sessionLoader.getSessionsCount(session);
|
||||
|
||||
for (int i=0 ; i<=count ; i+=sessionsPerSegment) {
|
||||
for (int i=0 ; i<count ; i+=sessionsPerSegment) {
|
||||
sessionLoader.loadSessions(session, i, sessionsPerSegment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -290,6 +290,14 @@ public class UserSessionPersisterProviderTest {
|
|||
realmMgr.removeRealm(realmMgr.getRealm("foo"));
|
||||
}
|
||||
|
||||
// KEYCLOAK-1999
|
||||
@Test
|
||||
public void testNoSessions() {
|
||||
UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class);
|
||||
List<UserSessionModel> sessions = persister.loadUserSessions(0, 1, true);
|
||||
Assert.assertEquals(0, sessions.size());
|
||||
}
|
||||
|
||||
|
||||
private ClientSessionModel createClientSession(ClientModel client, UserSessionModel userSession, String redirect, String state, Set<String> roles, Set<String> protocolMappers) {
|
||||
ClientSessionModel clientSession = session.sessions().createClientSession(realm, client);
|
||||
|
|
Loading…
Reference in a new issue