Skip to content

EhCacheFactoryBean.afterPropertiesSet should be synchronized [SPR-11132] #15758

@spring-projects-issues

Description

@spring-projects-issues

Vincent PERICART opened SPR-11132 and commented

When initializing 2 contexts at the same time, which both use a EhCacheFactoryBean, there is a potential race condition when :

  • the same CacheManager instance is used
  • both contexts have a cache with the same name

The error stack's root cause is :

Caused by: net.sf.ehcache.CacheException: Cannot replace XXX It does not equal the incumbent cache.
at net.sf.ehcache.CacheManager.replaceCacheWithDecoratedCache(CacheManager.java:1653)
at org.springframework.cache.ehcache.EhCacheFactoryBean.afterPropertiesSet(EhCacheFactoryBean.java:354)

The expected behaviour (which occurs most of the time) is that one of the contexts creates the cache, and the other one simply gets a reference to it.


Affects: 3.2.4

Referenced from: commits 1dc79f7, de890fd

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions