Skip to content

Commit ef1748f

Browse files
committed
EhCache/JCacheCacheManager needs to re-obtain runtime-added Cache reference for potential decoration
Issue: SPR-11407
1 parent 14e5a02 commit ef1748f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 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.
@@ -89,12 +89,11 @@ protected Collection<Cache> loadCaches() {
8989
public Cache getCache(String name) {
9090
Cache cache = super.getCache(name);
9191
if (cache == null) {
92-
// check the EhCache cache again
93-
// (in case the cache was added at runtime)
92+
// Check the EhCache cache again (in case the cache was added at runtime)
9493
Ehcache ehcache = getCacheManager().getEhcache(name);
9594
if (ehcache != null) {
96-
cache = new EhCacheCache(ehcache);
97-
addCache(cache);
95+
addCache(new EhCacheCache(ehcache));
96+
cache = super.getCache(name); // potentially decorated
9897
}
9998
}
10099
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-2013 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.
@@ -114,8 +114,8 @@ public Cache getCache(String name) {
114114
// Check the JCache cache again (in case the cache was added at runtime)
115115
javax.cache.Cache<Object, Object> jcache = getCacheManager().getCache(name);
116116
if (jcache != null) {
117-
cache = new JCacheCache(jcache, isAllowNullValues());
118-
addCache(cache);
117+
addCache(new JCacheCache(jcache, isAllowNullValues()));
118+
cache = super.getCache(name); // potentially decorated
119119
}
120120
}
121121
return cache;

0 commit comments

Comments
 (0)