You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
Had a problem with caches that seem to loose their expiry information.
Tracked down the problem to be caused by calling getCache on a non-existing cache.
It was used to check if the cache existed and if not, create it.
It looks like when JCacheManager.getCache() are not finding a cache in allCaches it
calls refreshallCaches() which will recreate them, but the expiry-configuration seems to be lost.
This test will show the error as the last assert will fail because the expiry-policy is lost.
@Test
public void testRefreshAllCachesError() {
final CachingProvider cachingProvider = Caching.getCachingProvider();
final CacheManager cacheManager = cachingProvider.getCacheManager();
String cacheNameExisting = "existingCache";
String cacheNameNonExisting = "nonExistingCache";
MutableConfiguration configuration = new MutableConfiguration();
configuration.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 60)));
configuration.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 60)));
cacheManager.createCache(cacheNameExisting, new JCacheConfiguration(configuration));
Cache<Object, Object> sampleCache = cacheManager.getCache(cacheNameExisting);
assertNotNull(sampleCache);
assertThat(sampleCache.getConfiguration(JCacheConfiguration.class).getExpiryPolicy().getExpiryForCreation().getDurationAmount(), is(60l));
// this will trigger refreshAllCaches which recreates caches
assertNull(cacheManager.getCache(cacheNameNonExisting));
// existing cache is OK but ...
assertThat(sampleCache.getConfiguration(JCacheConfiguration.class).getExpiryPolicy().getExpiryForCreation().getDurationAmount(), is(60l));
// ... if we fetch it again from cacheManager:
// this will fail as cache existingCache has been recreated and lost its expiry-policy
sampleCache = cacheManager.getCache(cacheNameExisting);
assertThat(sampleCache.getConfiguration(JCacheConfiguration.class).getExpiryPolicy().getExpiryForCreation().getDurationAmount(), is(60l));
}
The text was updated successfully, but these errors were encountered:
Had a problem with caches that seem to loose their expiry information.
Tracked down the problem to be caused by calling getCache on a non-existing cache.
It was used to check if the cache existed and if not, create it.
It looks like when JCacheManager.getCache() are not finding a cache in allCaches it
calls refreshallCaches() which will recreate them, but the expiry-configuration seems to be lost.
This test will show the error as the last assert will fail because the expiry-policy is lost.
The text was updated successfully, but these errors were encountered: