From af3c3ef15c5e79be78ae2cf3087658c408157a07 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 20 Mar 2013 10:05:56 +0100 Subject: [PATCH] Only call EhCacheManagerFactoryBean's destroy() method when actually initialized --- .../springframework/cache/ehcache/EhCacheSupportTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java index 492a0f868e..09a42c9e1f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java @@ -81,6 +81,7 @@ public class EhCacheSupportTests extends TestCase { private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exception { Cache cache; EhCacheManagerFactoryBean cacheManagerFb = null; + boolean cacheManagerFbInitialized = false; try { EhCacheFactoryBean cacheFb = new EhCacheFactoryBean(); Class objectType = cacheFb.getObjectType(); @@ -90,6 +91,7 @@ public class EhCacheSupportTests extends TestCase { cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass())); cacheManagerFb.afterPropertiesSet(); + cacheManagerFbInitialized = true; cacheFb.setCacheManager(cacheManagerFb.getObject()); } @@ -144,7 +146,7 @@ public class EhCacheSupportTests extends TestCase { assertTrue("overridden diskExpiryThreadIntervalSeconds is correct", config.getDiskExpiryThreadIntervalSeconds() == 10); } finally { - if (useCacheManagerFb && cacheManagerFb != null) { + if (cacheManagerFbInitialized) { cacheManagerFb.destroy(); } else {