HHH-12869 Do not check the cacheManager is not null when creating it
This commit is contained in:
parent
0d224e45d6
commit
5d5cfe82ef
|
@ -283,7 +283,9 @@ public class EhcacheRegionFactory extends RegionFactoryTemplate {
|
||||||
* Load a resource from the classpath.
|
* Load a resource from the classpath.
|
||||||
*/
|
*/
|
||||||
protected URL loadResource(String configurationResourceName) {
|
protected URL loadResource(String configurationResourceName) {
|
||||||
if ( ! isStarted() ) {
|
// we use this method to create the cache manager so we can't check it is non null
|
||||||
|
// calling the super method then
|
||||||
|
if ( ! super.isStarted() ) {
|
||||||
throw new IllegalStateException( "Cannot load resource through a non-started EhcacheRegionFactory" );
|
throw new IllegalStateException( "Cannot load resource through a non-started EhcacheRegionFactory" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||||
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
*/
|
||||||
|
package org.hibernate.cache.ehcache.test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cache.ehcache.ConfigSettings;
|
||||||
|
import org.hibernate.cache.ehcache.internal.SingletonEhcacheRegionFactory;
|
||||||
|
import org.hibernate.cache.spi.RegionFactory;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@TestForIssue(jiraKey = "HHH-12869")
|
||||||
|
public class SingletonEhCacheRegionFactoryClasspathConfigurationFileTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCacheInitialization() {
|
||||||
|
try ( SessionFactoryImplementor sessionFactory = TestHelper.buildStandardSessionFactory(
|
||||||
|
builder -> builder.applySetting( AvailableSettings.CACHE_REGION_FACTORY, "ehcache-singleton" )
|
||||||
|
.applySetting( ConfigSettings.EHCACHE_CONFIGURATION_RESOURCE_NAME,
|
||||||
|
"/hibernate-config/ehcache-configuration.xml" ) ) ) {
|
||||||
|
assertNotNull( sessionFactory );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!--
|
||||||
|
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
~
|
||||||
|
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
-->
|
||||||
|
<ehcache>
|
||||||
|
<diskStore path="java.io.tmpdir"/>
|
||||||
|
|
||||||
|
<!-- Domain caches -->
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.ehcache.test.domain.Item" maxElementsInMemory="10000" />
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.ehcache.test.domain.VersionedItem" maxElementsInMemory="10000" />
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.ehcache.test.domain.Event" maxElementsInMemory="10000" />
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.ehcache.test.domain.Event.participants" maxElementsInMemory="10000" />
|
||||||
|
|
||||||
|
<!-- Query caches with legacy names -->
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.spi.QueryResultsRegion" maxElementsInMemory="10000" />
|
||||||
|
<cache name="hibernate.test.org.hibernate.cache.spi.TimestampsRegion" maxElementsInMemory="10000" />
|
||||||
|
</ehcache>
|
Loading…
Reference in New Issue