From c7915fa95dc6fac505b783ab4529b765071a83e6 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Mon, 27 Jul 2015 08:52:00 +0200 Subject: [PATCH] KEYCLOAK-1699 There are 3 failed tests when running testsuite with -Pinfinispan --- .../infinispan/InfinispanUserSessionProvider.java | 13 ++++++++++++- .../test/resources/META-INF/keycloak-server.json | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java b/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java index 2202009c20..83776df17a 100755 --- a/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java +++ b/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProvider.java @@ -2,6 +2,7 @@ package org.keycloak.models.sessions.infinispan; import org.infinispan.Cache; import org.infinispan.distexec.mapreduce.MapReduceTask; +import org.jboss.logging.Logger; import org.keycloak.models.ClientModel; import org.keycloak.models.ClientSessionModel; import org.keycloak.models.KeycloakSession; @@ -41,6 +42,8 @@ import java.util.Map; */ public class InfinispanUserSessionProvider implements UserSessionProvider { + private static final Logger log = Logger.getLogger(InfinispanUserSessionProvider.class); + private final KeycloakSession session; private final Cache sessionCache; private final Cache loginFailureCache; @@ -473,6 +476,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { } public void put(Cache cache, Object key, Object value) { + log.tracev("Adding cache operation: {0} on {1}", CacheOperation.ADD, key); + if (tasks.containsKey(key)) { throw new IllegalStateException("Can't add session: task in progress for session"); } else { @@ -481,6 +486,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { } public void replace(Cache cache, Object key, Object value) { + log.tracev("Adding cache operation: {0} on {1}", CacheOperation.REPLACE, key); + CacheTask current = tasks.get(key); if (current != null) { switch (current.operation) { @@ -489,7 +496,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { current.value = value; return; case REMOVE: - throw new IllegalStateException("Can't remove session: task in progress for session"); + return; } } else { tasks.put(key, new CacheTask(cache, CacheOperation.REPLACE, key, value)); @@ -497,6 +504,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { } public void remove(Cache cache, Object key) { + log.tracev("Adding cache operation: {0} on {1}", CacheOperation.REMOVE, key); + tasks.put(key, new CacheTask(cache, CacheOperation.REMOVE, key, null)); } @@ -514,6 +523,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider { } public void execute() { + log.tracev("Executing cache operation: {0} on {1}", operation, key); + switch (operation) { case ADD: cache.put(key, value); diff --git a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json index 277a708e5b..c760152991 100755 --- a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json +++ b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json @@ -23,15 +23,15 @@ }, "userSessions": { - "provider" : "${keycloak.userSessions.provider:mem}" + "provider" : "${keycloak.userSessions.provider:infinispan}" }, "realmCache": { - "provider": "${keycloak.realm.cache.provider:mem}" + "provider": "${keycloak.realm.cache.provider:infinispan}" }, "userCache": { - "provider": "${keycloak.user.cache.provider:mem}", + "provider": "${keycloak.user.cache.provider:infinispan}", "mem": { "maxSize": 20000 }