diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanAuthenticationSessionProvider.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanAuthenticationSessionProvider.java index 367547057c..12019c1b43 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanAuthenticationSessionProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanAuthenticationSessionProvider.java @@ -120,7 +120,7 @@ public class InfinispanAuthenticationSessionProvider implements AuthenticationSe while (itr.hasNext()) { counter++; RootAuthenticationSessionEntity entity = itr.next().getValue(); - tx.remove(CacheDecorators.localCache(cache), entity.getId()); + tx.remove(cache, entity.getId()); } log.debugf("Removed %d expired authentication sessions for realm '%s'", counter, realm.getName()); diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java index c0b1aa05d6..709c417fd0 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java @@ -476,8 +476,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { // Each cluster node cleanups just local sessions, which are those owned by itself (+ few more taking l1 cache into account) Cache> localCache = CacheDecorators.localCache(sessionCache); - Cache> localClientSessionCache = CacheDecorators.localCache(clientSessionCache); - Cache> localCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localCache); final AtomicInteger userSessionsSize = new AtomicInteger(); @@ -495,12 +493,12 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { public void accept(UserSessionEntity userSessionEntity) { userSessionsSize.incrementAndGet(); - Future future = localCache.removeAsync(userSessionEntity.getId()); + Future future = sessionCache.removeAsync(userSessionEntity.getId()); futures.addTask(future); userSessionEntity.getAuthenticatedClientSessions().forEach((clientUUID, clientSessionId) -> { clientSessionsSize.incrementAndGet(); - Future f = localClientSessionCache.removeAsync(clientSessionId); + Future f = clientSessionCache.removeAsync(clientSessionId); futures.addTask(f); }); } @@ -508,9 +506,10 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { }); // Removing detached clientSessions. Ignore remoteStore for stream iteration. But we will invoke remoteStore for clientSession removal propagate - Cache> localCacheStoreIgnoreClientSessionCache = CacheDecorators.localCache(localClientSessionCache); + Cache> localClientSessionCache = CacheDecorators.localCache(clientSessionCache); + Cache> localClientSessionCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localClientSessionCache); - localCacheStoreIgnoreClientSessionCache + localClientSessionCacheStoreIgnore .entrySet() .stream() .filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expired)) @@ -521,7 +520,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { public void accept(AuthenticatedClientSessionEntity clientSessionEntity) { clientSessionsSize.incrementAndGet(); - Future future = localClientSessionCache.removeAsync(clientSessionEntity.getId()); + Future future = clientSessionCache.removeAsync(clientSessionEntity.getId()); futures.addTask(future); } @@ -539,7 +538,6 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { // Each cluster node cleanups just local sessions, which are those owned by himself (+ few more taking l1 cache into account) Cache> localCache = CacheDecorators.localCache(offlineSessionCache); - Cache> localClientSessionCache = CacheDecorators.localCache(offlineClientSessionCache); UserSessionPredicate predicate = UserSessionPredicate.create(realm.getId()).expired(null, expiredOffline); @@ -562,11 +560,11 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { public void accept(UserSessionEntity userSessionEntity) { userSessionsSize.incrementAndGet(); - Future future = localCache.removeAsync(userSessionEntity.getId()); + Future future = offlineSessionCache.removeAsync(userSessionEntity.getId()); futures.addTask(future); userSessionEntity.getAuthenticatedClientSessions().forEach((clientUUID, clientSessionId) -> { clientSessionsSize.incrementAndGet(); - Future f = localClientSessionCache.removeAsync(clientSessionId); + Future f = offlineClientSessionCache.removeAsync(clientSessionId); futures.addTask(f); }); @@ -575,11 +573,11 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { } }); - // Removing detached clientSessions. Ignore remoteStore for stream iteration. But we will invoke remoteStore for clientSession removal propagate - Cache> localCacheStoreIgnoreClientSessionCache = CacheDecorators.localCache(localClientSessionCache); + Cache> localClientSessionCache = CacheDecorators.localCache(offlineClientSessionCache); + Cache> localClientSessionCacheStoreIgnore = CacheDecorators.skipCacheLoaders(localClientSessionCache); - localCacheStoreIgnoreClientSessionCache + localClientSessionCacheStoreIgnore .entrySet() .stream() .filter(AuthenticatedClientSessionPredicate.create(realm.getId()).expired(expiredOffline)) @@ -590,7 +588,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { public void accept(AuthenticatedClientSessionEntity clientSessionEntity) { clientSessionsSize.incrementAndGet(); - Future future = localClientSessionCache.removeAsync(clientSessionEntity.getId()); + Future future = offlineClientSessionCache.removeAsync(clientSessionEntity.getId()); futures.addTask(future); }