Skip to content

Exposure of setStatisticsEnabled/setSampledStatisticsEnabled causes cache not initialized exception when chaches are defined as spring beans. [SPR-9392] #14028

@spring-projects-issues

Description

@spring-projects-issues

David G opened SPR-9392 and commented

The enhancement provided with #13497 causes an unintended side-effect during initialization of the cache via the factory.

When creating a cache by the factory bean, the method create cache attempts to set the properties statistics, sampledStatistics, and disabled before returning the cache. At the time this occurs the cache has not been registered with the cache manager and has not as yet been initialized. This is not a problem for disabled, but statistics & sampledStatistics both check to see if the cache has been initialized.

Would it be possible to move the code for the statistics & sampledStatistic up to afterPropertiesSet just before attempting to decorate the cache?

Obvious workaround would be to define the cache in the ehcache.xml configuration. This unfortunately is not workable for my current project.

I have emailed Jeurgen Hoeller with regard to this as well.


Affects: 3.1.1

Reference URL: http://forum.springsource.org/showthread.php?126252-EhCacheFactoryBean-amp-statistics-enablement

Referenced from: commits dcb4426, 08784f3

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