Skip to content

Commit

Permalink
EhCache/JCacheCacheManager needs to re-obtain runtime-added Cache ref…
Browse files Browse the repository at this point in the history
…erence for potential decoration

Issue: SPR-11407
  • Loading branch information
jhoeller committed Feb 14, 2014
1 parent 14e5a02 commit ef1748f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,12 +89,11 @@ protected Collection<Cache> loadCaches() {
public Cache getCache(String name) {
Cache cache = super.getCache(name);
if (cache == null) {
// check the EhCache cache again
// (in case the cache was added at runtime)
// Check the EhCache cache again (in case the cache was added at runtime)
Ehcache ehcache = getCacheManager().getEhcache(name);
if (ehcache != null) {
cache = new EhCacheCache(ehcache);
addCache(cache);
addCache(new EhCacheCache(ehcache));
cache = super.getCache(name); // potentially decorated
}
}
return cache;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -114,8 +114,8 @@ public Cache getCache(String name) {
// Check the JCache cache again (in case the cache was added at runtime)
javax.cache.Cache<Object, Object> jcache = getCacheManager().getCache(name);
if (jcache != null) {
cache = new JCacheCache(jcache, isAllowNullValues());
addCache(cache);
addCache(new JCacheCache(jcache, isAllowNullValues()));
cache = super.getCache(name); // potentially decorated
}
}
return cache;
Expand Down

0 comments on commit ef1748f

Please sign in to comment.