mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Synchronized cache creation on CacheManager
Issue: SPR-11132
This commit is contained in:
Vendored
+3
-1
@@ -31,9 +31,9 @@ import net.sf.ehcache.constructs.blocking.SelfPopulatingCache;
|
|||||||
import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory;
|
import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory;
|
||||||
import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache;
|
import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache;
|
||||||
import net.sf.ehcache.event.CacheEventListener;
|
import net.sf.ehcache.event.CacheEventListener;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
@@ -230,6 +230,7 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
|
|||||||
this.cacheManager = CacheManager.getInstance();
|
this.cacheManager = CacheManager.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized (this.cacheManager) {
|
||||||
// Fetch cache region: If none with the given name exists, create one on the fly.
|
// Fetch cache region: If none with the given name exists, create one on the fly.
|
||||||
Ehcache rawCache;
|
Ehcache rawCache;
|
||||||
boolean cacheExists = this.cacheManager.cacheExists(cacheName);
|
boolean cacheExists = this.cacheManager.cacheExists(cacheName);
|
||||||
@@ -271,6 +272,7 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
|
|||||||
}
|
}
|
||||||
this.cache = decoratedCache;
|
this.cache = decoratedCache;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a raw Cache object based on the configuration of this FactoryBean.
|
* Create a raw Cache object based on the configuration of this FactoryBean.
|
||||||
|
|||||||
Reference in New Issue
Block a user