From ef1748f69444053a9bece0df76859ee10cc1550c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 14 Feb 2014 21:58:48 +0100 Subject: [PATCH] EhCache/JCacheCacheManager needs to re-obtain runtime-added Cache reference for potential decoration Issue: SPR-11407 --- .../cache/ehcache/EhCacheCacheManager.java | 9 ++++----- .../springframework/cache/jcache/JCacheCacheManager.java | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index b6b538fa82..212f5d6e0d 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -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. @@ -89,12 +89,11 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag 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; diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java index 46574013a0..453f87828b 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java @@ -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. @@ -114,8 +114,8 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage // Check the JCache cache again (in case the cache was added at runtime) javax.cache.Cache 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;