From 623fcfeff1d202ed4990b3e15da088a0023fc0c7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 30 Sep 2015 14:36:39 +0200 Subject: [PATCH] Properly guard cache statistics providers Previously, a `NoClassDefFoundError` could be thrown if EhCache or Guava is on the classpath without `spring-context-support` as the respective cache statistics provider both needs the implementation and the spring abstraction implementation. The `@ConditionalOnClass` definition has been updated to properly guard those beans. Closes gh-3960 --- .../autoconfigure/CacheStatisticsAutoConfiguration.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java index 2ae7b982b5..d26dccd15a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java @@ -36,6 +36,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCache; +import org.springframework.cache.ehcache.EhCacheCache; +import org.springframework.cache.guava.GuavaCache; import org.springframework.cache.jcache.JCacheCache; import org.springframework.cache.support.NoOpCacheManager; import org.springframework.context.annotation.Bean; @@ -71,7 +73,7 @@ public class CacheStatisticsAutoConfiguration { } @Configuration - @ConditionalOnClass(Ehcache.class) + @ConditionalOnClass({ EhCacheCache.class, Ehcache.class }) static class EhCacheCacheStatisticsProviderConfiguration { @Bean @@ -103,7 +105,7 @@ public class CacheStatisticsAutoConfiguration { } @Configuration - @ConditionalOnClass(com.google.common.cache.Cache.class) + @ConditionalOnClass({ com.google.common.cache.Cache.class, GuavaCache.class }) static class GuavaCacheStatisticsConfiguration { @Bean