[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-6871) SingletonEhCacheProvider shoud not shutdown singleton CacheManager if it doesn't own it

Steve Ebersole (JIRA) noreply at atlassian.com
Wed Jan 11 13:11:10 EST 2012


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6871?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole updated HHH-6871:
--------------------------------

    Fix Version/s:     (was: 4.0.1)

> SingletonEhCacheProvider shoud not shutdown singleton CacheManager if it doesn't own it
> ---------------------------------------------------------------------------------------
>
>                 Key: HHH-6871
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6871
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: caching (L2)
>    Affects Versions: 3.6.8, 4.0.0.CR7
>            Reporter: Adrien
>            Priority: Minor
>              Labels: ehcache
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> SingletonEhCacheProvider use a static referenceCount every time a sessionFactory wants a CacheManager, and shutdown it when all sessionFactories are gone. But Hibernate may not be the only one using it. In our case, we have manual configuration of the CacheManager singleton and cache regions not managed by Hibernate. The simple fact of creating a SessionFactory, then close it shutdown the singleton, with our configuration and cache regions.
> It's hard to know if Hibernate is the only one using EhCache and it's cool that Hibernate close the EhCache threads for most configurations, but in our case, it's a real problem. We manually call new SingletonEhCacheProvider().start(null) to increment the referenceCount, but others will have the problem.
> My proposition is that before accessing for the first time to the CacheManager (referenceCount, Hibernate check if it's already exist (meaning it's already been used by someoneelse). If so, it increment the referenceCount to be sure Hibernate will never shutdown the CacheManager. Something like :
> public void start(Settings settings, Properties properties) throws CacheException {
>   (...)
>   if (referenceCount.get() == 0 && CacheManager.getCacheManager(null) != null) {
>     REFERENCE_COUNT.incrementAndGet();
>   }
>   (...)
> }
> There may be some multi-thread issues with this code, but it's just the idea.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list