diff --git a/ehcache-107/src/main/java/org/ehcache/jsr107/Eh107CacheManager.java b/ehcache-107/src/main/java/org/ehcache/jsr107/Eh107CacheManager.java index 0af2001399..49fba53e4e 100644 --- a/ehcache-107/src/main/java/org/ehcache/jsr107/Eh107CacheManager.java +++ b/ehcache-107/src/main/java/org/ehcache/jsr107/Eh107CacheManager.java @@ -81,11 +81,6 @@ class Eh107CacheManager implements CacheManager { } - private Eh107Cache wrapEhcacheCache(String alias, CacheConfiguration ehConfig) { - org.ehcache.Cache cache = ehCacheManager.getCache(alias, ehConfig.getKeyType(), ehConfig.getValueType()); - return wrapEhcacheCache(alias, (InternalCache)cache); - } - private void loadCache(String cacheName) { Map> cacheConfigurations = ehCacheManager.getRuntimeConfiguration().getCacheConfigurations(); CacheConfiguration cacheConfiguration; @@ -103,7 +98,11 @@ private void loadCache(String cacheName) { } } } + } + private Eh107Cache wrapEhcacheCache(String alias, CacheConfiguration ehConfig) { + org.ehcache.Cache cache = ehCacheManager.getCache(alias, ehConfig.getKeyType(), ehConfig.getValueType()); + return wrapEhcacheCache(alias, (InternalCache)cache); } private Eh107Cache wrapEhcacheCache(String alias, InternalCache cache) { @@ -173,6 +172,7 @@ public > Cache createCache(String cach throw new CacheException("A Cache named [" + cacheName + "] already exists"); } Eh107Cache cache = wrapEhcacheCache(cacheName, (InternalCache)ehcache); + assert safeCacheRetrieval(cacheName) == null; lazilyLoadedCaches.put(cacheName, cache); @SuppressWarnings("unchecked") @@ -246,6 +246,7 @@ public String toString() { @Override public Cache getCache(String cacheName, Class keyType, Class valueType) { checkClosed(); + loadCache(cacheName); if (cacheName == null || keyType == null || valueType == null) { throw new NullPointerException(); @@ -276,6 +277,7 @@ public Cache getCache(String cacheName, Class keyType, Class @Override public Cache getCache(String cacheName) { checkClosed(); + loadCache(cacheName); if (cacheName == null) { throw new NullPointerException(); @@ -286,7 +288,6 @@ public Cache getCache(String cacheName) { @SuppressWarnings("unchecked") private Eh107Cache safeCacheRetrieval(final String cacheName) { - loadCache(cacheName); final Eh107Cache eh107Cache = lazilyLoadedCaches.get(cacheName); if(eh107Cache != null && eh107Cache.isClosed()) { return null;