From ec49d1000722290d8593d0d75f547e2a9a1ade43 Mon Sep 17 00:00:00 2001 From: mposolda Date: Wed, 30 Nov 2016 08:38:35 +0100 Subject: [PATCH] KEYCLOAK-3997 InfinispanKeyStorageProviderTest was failing --- .../infinispan/InfinispanPublicKeyStorageProvider.java | 8 +++++++- .../keys/infinispan/InfinispanKeyStorageProviderTest.java | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/model/infinispan/src/main/java/org/keycloak/keys/infinispan/InfinispanPublicKeyStorageProvider.java b/model/infinispan/src/main/java/org/keycloak/keys/infinispan/InfinispanPublicKeyStorageProvider.java index edfd392c6c..b5f48cd5bb 100644 --- a/model/infinispan/src/main/java/org/keycloak/keys/infinispan/InfinispanPublicKeyStorageProvider.java +++ b/model/infinispan/src/main/java/org/keycloak/keys/infinispan/InfinispanPublicKeyStorageProvider.java @@ -55,12 +55,13 @@ public class InfinispanPublicKeyStorageProvider implements PublicKeyStorageProvi private Set invalidations = new HashSet<>(); + private boolean transactionEnlisted = false; + public InfinispanPublicKeyStorageProvider(KeycloakSession session, Cache keys, Map> tasksInProgress, int minTimeBetweenRequests) { this.session = session; this.keys = keys; this.tasksInProgress = tasksInProgress; this.minTimeBetweenRequests = minTimeBetweenRequests; - session.getTransactionManager().enlistAfterCompletion(getAfterTransaction()); } @@ -73,6 +74,11 @@ public class InfinispanPublicKeyStorageProvider implements PublicKeyStorageProvi void addInvalidation(String cacheKey) { + if (!transactionEnlisted) { + session.getTransactionManager().enlistAfterCompletion(getAfterTransaction()); + transactionEnlisted = true; + } + this.invalidations.add(cacheKey); } diff --git a/model/infinispan/src/test/java/org/keycloak/keys/infinispan/InfinispanKeyStorageProviderTest.java b/model/infinispan/src/test/java/org/keycloak/keys/infinispan/InfinispanKeyStorageProviderTest.java index ffd355c8a8..77dd98952f 100644 --- a/model/infinispan/src/test/java/org/keycloak/keys/infinispan/InfinispanKeyStorageProviderTest.java +++ b/model/infinispan/src/test/java/org/keycloak/keys/infinispan/InfinispanKeyStorageProviderTest.java @@ -45,7 +45,6 @@ import org.keycloak.keys.PublicKeyLoader; /** * @author Marek Posolda */ -@Ignore public class InfinispanKeyStorageProviderTest { private Map counters = new ConcurrentHashMap<>();