From b4662292312a0cbf8860246afffa975e3e8690d3 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 13 May 2015 18:18:15 +0200 Subject: [PATCH] Restore proper customization of JCache CacheManager Work in 1b3efd4 actually introduced a regression: if a CacheManager is created via a custom configuration file, it is no longer post-processed. This commit makes sure to also customize a CacheManager that was created that way. See gh-2848 --- .../cache/JCacheCacheConfiguration.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java index d4a6a6fc41e..5ecc03e968e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/JCacheCacheConfiguration.java @@ -77,15 +77,7 @@ class JCacheCacheConfiguration { @Bean @ConditionalOnMissingBean public CacheManager jCacheCacheManager() throws IOException { - CachingProvider cachingProvider = getCachingProvider(this.cacheProperties - .getJcache().getProvider()); - Resource configLocation = this.cacheProperties.resolveConfigLocation(); - if (configLocation != null) { - return cachingProvider.getCacheManager(configLocation.getURI(), - cachingProvider.getDefaultClassLoader(), - createCacheManagerProperties(configLocation)); - } - CacheManager jCacheCacheManager = cachingProvider.getCacheManager(); + CacheManager jCacheCacheManager = createCacheManager(); List cacheNames = this.cacheProperties.getCacheNames(); if (!CollectionUtils.isEmpty(cacheNames)) { for (String cacheName : cacheNames) { @@ -96,6 +88,18 @@ class JCacheCacheConfiguration { return jCacheCacheManager; } + private CacheManager createCacheManager() throws IOException { + CachingProvider cachingProvider = getCachingProvider(this.cacheProperties + .getJcache().getProvider()); + Resource configLocation = this.cacheProperties.resolveConfigLocation(); + if (configLocation != null) { + return cachingProvider.getCacheManager(configLocation.getURI(), + cachingProvider.getDefaultClassLoader(), + createCacheManagerProperties(configLocation)); + } + return cachingProvider.getCacheManager(); + } + private CachingProvider getCachingProvider(String cachingProviderFqn) { if (StringUtils.hasText(cachingProviderFqn)) { return Caching.getCachingProvider(cachingProviderFqn);