coheigea commented on code in PR #3696:
URL: https://github.com/apache/cxf/pull/3696#discussion_r4513606945


##########
rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/jcache/JCacheTokenReplayCache.java:
##########
@@ -99,19 +106,29 @@ protected JCacheTokenReplayCache(String cacheKey, String 
configFile, String defa
             ? resolvedConfigFileURL.toURI() : cachingProvider.getDefaultURI();
         cacheManager = cachingProvider.getCacheManager(configURI, 
getClass().getClassLoader());
 
-        cache = getOrCreate(cacheManager, cacheKey, String.class, 
EHCacheValue.class);
-    }
-
-    private static <K, V> Cache<K, V> getOrCreate(CacheManager cacheManager, 
String name,
-            Class<K> kclass, Class<V> vclass) {
+        Cache<String, EHCacheValue> configuredCache =
+            cacheManager.getCache(cacheKey, String.class, EHCacheValue.class);
+        cache = configuredCache != null ? configuredCache : 
createCache(cacheManager, cacheKey);
 
-        final Cache<K, V> cache = cacheManager.getCache(name, kclass, vclass);
-        if (cache != null) {
-            return cache;
-        }
+        // With the default configuration, the cache uses EHCacheExpiry, which 
holds an entry for at most

Review Comment:
   Thanks, good idea, but it doesn’t work with Ehcache’s own config: 
getExpiryPolicyFactory() throws UnsupportedOperationException for any cache 
whose expiry comes from the Ehcache XML, including our default one. 
(EHCacheExpiry is per-entry anyway, so there’s no single duration to read.)
   
   So I’ve done both in the follow-up commit: read it from the JCache expiry 
policy when we can (shortest of the creation/access/update durations, null if 
eternal), and otherwise fall back to the old check (12h for the default config, 
unknown for anything else).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to