diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedCacheRealmProvider.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedCacheRealmProvider.java index 7294db9d45..d241519aef 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedCacheRealmProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedCacheRealmProvider.java @@ -211,11 +211,12 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { logger.tracev("by id cache hit: {0}", cached.getName()); } if (cached == null) { - Long loaded = cache.getCurrentRevision(id); + Long loaded = UpdateCounter.current(); RealmModel model = getDelegate().getRealm(id); if (model == null) return null; if (realmInvalidations.contains(id)) return model; cached = new RevisionedCachedRealm(loaded, cache, this, model); + logger.tracev("try caching realm: {0} {1}", cached.getName(), loaded); cache.addCachedRealm(cached); } else if (realmInvalidations.contains(id)) { return getDelegate().getRealm(id); @@ -234,10 +235,12 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { logger.tracev("by name cache hit: {0}", cached.getName()); } if (cached == null) { + Long loaded = UpdateCounter.current(); RealmModel model = getDelegate().getRealmByName(name); if (model == null) return null; if (realmInvalidations.contains(model.getId())) return model; - cached = new RevisionedCachedRealm(null, cache, this, model); + cached = new RevisionedCachedRealm(loaded, cache, this, model); + logger.tracev("try caching realm: {0}", cached.getName()); cache.addCachedRealm(cached); } else if (realmInvalidations.contains(cached.getId())) { return getDelegate().getRealmByName(name); @@ -299,7 +302,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { } if (cached == null) { - Long loaded = cache.getCurrentRevision(id); + Long loaded = UpdateCounter.current(); RoleModel model = getDelegate().getRoleById(id, realm); if (model == null) return null; if (roleInvalidations.contains(id)) return model; @@ -328,7 +331,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { } if (cached == null) { - Long loaded = cache.getCurrentRevision(id); + Long loaded = UpdateCounter.current(); GroupModel model = getDelegate().getGroupById(id, realm); if (model == null) return null; if (groupInvalidations.contains(id)) return model; @@ -356,7 +359,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { } if (cached == null) { - Long loaded = cache.getCurrentRevision(id); + Long loaded = UpdateCounter.current(); ClientModel model = getDelegate().getClientById(id, realm); if (model == null) return null; if (appInvalidations.contains(id)) return model; @@ -379,7 +382,7 @@ public class RevisionedCacheRealmProvider implements CacheRealmProvider { } if (cached == null) { - Long loaded = cache.getCurrentRevision(id); + Long loaded = UpdateCounter.current(); ClientTemplateModel model = getDelegate().getClientTemplateById(id, realm); if (model == null) return null; if (clientTemplateInvalidations.contains(id)) return model; diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedRealmCache.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedRealmCache.java index b6fb89c340..f32836ee20 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedRealmCache.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/counter/RevisionedRealmCache.java @@ -51,11 +51,6 @@ public class RevisionedRealmCache implements RealmCache { return cache; } - public Long getCurrentRevision(String id) { - //return revisions.get(id); - return UpdateCounter.current(); - } - private T get(String id, Class type) { Revisioned o = (Revisioned)cache.get(id); if (o == null) { @@ -83,12 +78,12 @@ public class RevisionedRealmCache implements RealmCache { protected void addRevisioned(String id, Revisioned object) { Long rev = revisions.get(id); if (rev == null) { + logger.tracev("rev was null in addRevisioned, adding one"); rev = UpdateCounter.next(); revisions.put(id, rev); + return; } - if (rev.equals(object.getRevision())) { - cache.putForExternalRead(id, object); - } + cache.putForExternalRead(id, object); } 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 155c8d0e65..a2f93cde96 100755 --- a/testsuite/integration/src/test/resources/META-INF/keycloak-server.json +++ b/testsuite/integration/src/test/resources/META-INF/keycloak-server.json @@ -32,13 +32,6 @@ } }, - "realmCache": { - "provider": "infinispan-revisioned", - "infinispan-locking" : { - "enabled": true - } - }, - "timer": { "provider": "basic" }, @@ -85,8 +78,15 @@ } }, + "realmCache": { + "provider": "infinispan-locking", + "infinispan-locking" : { + "enabled": true + } + }, + "connectionsInfinispan": { - "provider": "revisioned", + "provider": "locking", "locking": { "clustered": "${keycloak.connectionsInfinispan.clustered:false}", "async": "${keycloak.connectionsInfinispan.async:true}",