Only call EhCacheManagerFactoryBean's destroy() method when actually initialized
This commit is contained in:
parent
5472e975f6
commit
af3c3ef15c
|
@ -81,6 +81,7 @@ public class EhCacheSupportTests extends TestCase {
|
||||||
private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exception {
|
private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exception {
|
||||||
Cache cache;
|
Cache cache;
|
||||||
EhCacheManagerFactoryBean cacheManagerFb = null;
|
EhCacheManagerFactoryBean cacheManagerFb = null;
|
||||||
|
boolean cacheManagerFbInitialized = false;
|
||||||
try {
|
try {
|
||||||
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
|
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
|
||||||
Class<? extends Ehcache> objectType = cacheFb.getObjectType();
|
Class<? extends Ehcache> objectType = cacheFb.getObjectType();
|
||||||
|
@ -90,6 +91,7 @@ public class EhCacheSupportTests extends TestCase {
|
||||||
cacheManagerFb = new EhCacheManagerFactoryBean();
|
cacheManagerFb = new EhCacheManagerFactoryBean();
|
||||||
cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass()));
|
cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass()));
|
||||||
cacheManagerFb.afterPropertiesSet();
|
cacheManagerFb.afterPropertiesSet();
|
||||||
|
cacheManagerFbInitialized = true;
|
||||||
cacheFb.setCacheManager(cacheManagerFb.getObject());
|
cacheFb.setCacheManager(cacheManagerFb.getObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +146,7 @@ public class EhCacheSupportTests extends TestCase {
|
||||||
assertTrue("overridden diskExpiryThreadIntervalSeconds is correct", config.getDiskExpiryThreadIntervalSeconds() == 10);
|
assertTrue("overridden diskExpiryThreadIntervalSeconds is correct", config.getDiskExpiryThreadIntervalSeconds() == 10);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (useCacheManagerFb && cacheManagerFb != null) {
|
if (cacheManagerFbInitialized) {
|
||||||
cacheManagerFb.destroy();
|
cacheManagerFb.destroy();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue