Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue May 9, 2012 · 2 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 9, 2012

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 9, 2012

David G commented

Sorry I forgot to mention, I am working with ehcache 2.5.2.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 9, 2012

David G commented

I think I may have found why this has become a problem.

The spring code base for 3.1.1 is using ehcache-2.0.0.

My application is attempting to use ehcache-2.5.2.

Somewhere between ehcache-2.0.0 and ehcache-2.5.2 the setStatisticsEnabled method was altered to provide propertyChange event notification semantics.

As such, it checks the method isStatisticsEnabled(). This method requires that the cache be initialized prior to calling.

As such, using Ehcache 2.5.2 with Spring 3.1.1 and attempting to set statisticsEnabled or sampledStatisticsEnabled will fail with an IllegalStateException.

Unfortunately there is no unit test coverage on this particular case as it isn't exercised within the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants