From 9ed5fc5595f451ed714ac2fd2390162086c2a05d Mon Sep 17 00:00:00 2001 From: Pedro Igor Date: Tue, 5 Sep 2017 11:45:01 -0300 Subject: [PATCH] [KEYCLOAK-5389] - Invalidating ResourceStore.findByUri cache when creating new resources --- .../infinispan/authorization/StoreFactoryCacheSession.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/authorization/StoreFactoryCacheSession.java b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/authorization/StoreFactoryCacheSession.java index 27bacc45b0..2efdd91f2a 100644 --- a/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/authorization/StoreFactoryCacheSession.java +++ b/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/authorization/StoreFactoryCacheSession.java @@ -509,8 +509,9 @@ public class StoreFactoryCacheSession implements CachedStoreFactoryProvider { @Override public Resource create(String name, ResourceServer resourceServer, String owner) { Resource resource = getResourceStoreDelegate().create(name, resourceServer, owner); + Resource cached = findById(resource.getId(), resourceServer.getId()); registerResourceInvalidation(resource.getId(), resource.getName(), resource.getType(), resource.getUri(), resource.getScopes().stream().map(scope -> scope.getId()).collect(Collectors.toSet()), resourceServer.getId(), resource.getOwner()); - return resource; + return cached; } @Override