Skip to content

Commit 42dec02

Browse files
committed
EhCache/JCacheCacheManager needs to re-obtain runtime-added Cache reference for potential decoration
Issue: SPR-11407 (cherry picked from commit ef1748f)
1 parent 27ad199 commit 42dec02

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public EhCacheCacheManager() {
4646
}
4747

4848
/**
49-
* Create a new EhCacheCacheManager for the given backing EhCache.
49+
* Create a new EhCacheCacheManager for the given backing EhCache CacheManager.
5050
* @param cacheManager the backing EhCache {@link net.sf.ehcache.CacheManager}
5151
*/
5252
public EhCacheCacheManager(net.sf.ehcache.CacheManager cacheManager) {
@@ -92,8 +92,8 @@ public Cache getCache(String name) {
9292
// (in case the cache was added at runtime)
9393
Ehcache ehcache = this.cacheManager.getEhcache(name);
9494
if (ehcache != null) {
95-
cache = new EhCacheCache(ehcache);
96-
addCache(cache);
95+
addCache(new EhCacheCache(ehcache));
96+
cache = super.getCache(name); // potentially decorated
9797
}
9898
}
9999
return cache;

spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -110,8 +110,8 @@ public Cache getCache(String name) {
110110
// (in case the cache was added at runtime)
111111
javax.cache.Cache<?,?> jcache = this.cacheManager.getCache(name);
112112
if (jcache != null) {
113-
cache = new JCacheCache(jcache, this.allowNullValues);
114-
addCache(cache);
113+
addCache(new JCacheCache(jcache, this.allowNullValues));
114+
cache = super.getCache(name); // potentially decorated
115115
}
116116
}
117117
return cache;

0 commit comments

Comments
 (0)