-
Notifications
You must be signed in to change notification settings - Fork 38.5k
EhCacheCacheManager does not close underlying CacheManager [SPR-11680] #16303
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
Comments
Michael Russo commented I'm intending to configure a Spring MVC Web project to use Ehcache via java config. I found one suggestion for doing this via stackoverflow: http://stackoverflow.com/questions/21944202/using-ehcache-in-spring-4-without-xml The answer shows the creation of a org.springframework.cache.CacheManager spring bean by using the org.springframework.cache.ehcache.EhCacheCacheManager. The problem with this answer is that the EhCacheCacheManager doesn't seem to support closing the underlying EhCache CacheManager by calling its shutdown() method. When using XML config, the common practice is to use the EhCacheManagerFactoryBean, which happens to implement DisposableBean and calls cacheManager.shutdown() as expected. This looks like a bug to me. I believe the EhCacheCacheManager should also register a destroy method that calls cacheManager.shutdown(). |
Juergen Hoeller commented Since EhCacheCacheManager is set up with an externally specified CacheManager, it has an adapter role and isn't really meant to control the lifecycle of that external CacheManager instance. Instead, it's advisable to define the native net.sf.ehcache.CacheManager as a dedicated bean (using XML or using an Hope that helps, Juergen |
Michael Russo commented That helps a lot, thanks! I verified that when registering net.sf.ehcache.CacheManager as a bean, its shutdown method is called successfully, without me even having to specify the bean's destroyMethod. The part I still don't understand is, how is this automatic? The documentation for the
Either way, consider this issue resolved. Thanks for your help! |
Juergen Hoeller commented The automatic detection of "shutdown()" is a rather recent effect: see #14347. Seems we have to mention this in the Juergen |
Juergen Hoeller commented Marking this as "Won't Fix" from the EhCacheCacheManager perspective. |
Michael Russo opened SPR-11680 and commented
EhCacheCacheManager should implement and register a destroy method that calls cacheManager.shutdown(), which should be called when EhCacheCacheManager bean is destroyed by Spring container.
When using XML config, the common practice is to use the EhCacheManagerFactoryBean, which happens to implement DisposableBean and calls cacheManager.shutdown() as expected.
Affects: 4.0.3
Issue Links:
@Bean
The text was updated successfully, but these errors were encountered: