EhCacheManagerFactoryBean properly closes "ehcache.xml" input stream, if any (SPR-7813)
This commit is contained in:
parent
cc91efecae
commit
67d9b8b943
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.cache.ehcache;
|
package org.springframework.cache.ehcache;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import net.sf.ehcache.CacheException;
|
import net.sf.ehcache.CacheException;
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
|
|
@ -97,23 +98,17 @@ public class EhCacheManagerFactoryBean implements FactoryBean<CacheManager>, Ini
|
||||||
|
|
||||||
public void afterPropertiesSet() throws IOException, CacheException {
|
public void afterPropertiesSet() throws IOException, CacheException {
|
||||||
logger.info("Initializing EHCache CacheManager");
|
logger.info("Initializing EHCache CacheManager");
|
||||||
if (this.shared) {
|
if (this.configLocation != null) {
|
||||||
// Shared CacheManager singleton at the VM level.
|
InputStream is = this.configLocation.getInputStream();
|
||||||
if (this.configLocation != null) {
|
try {
|
||||||
this.cacheManager = CacheManager.create(this.configLocation.getInputStream());
|
this.cacheManager = (this.shared ? CacheManager.create(is) : new CacheManager(is));
|
||||||
}
|
}
|
||||||
else {
|
finally {
|
||||||
this.cacheManager = CacheManager.create();
|
is.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Independent CacheManager instance (the default).
|
this.cacheManager = (this.shared ? CacheManager.create() : new CacheManager());
|
||||||
if (this.configLocation != null) {
|
|
||||||
this.cacheManager = new CacheManager(this.configLocation.getInputStream());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.cacheManager = new CacheManager();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.cacheManagerName != null) {
|
if (this.cacheManagerName != null) {
|
||||||
this.cacheManager.setName(this.cacheManagerName);
|
this.cacheManager.setName(this.cacheManagerName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue