Browse Source

Only call EhCacheManagerFactoryBean's destroy() method when actually initialized

pull/263/head
Juergen Hoeller 12 years ago
parent
commit
af3c3ef15c
  1. 4
      spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java

4
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java vendored

@ -81,6 +81,7 @@ public class EhCacheSupportTests extends TestCase { @@ -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<? extends Ehcache> objectType = cacheFb.getObjectType();
@ -90,6 +91,7 @@ public class EhCacheSupportTests extends TestCase { @@ -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 { @@ -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 {

Loading…
Cancel
Save