Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit b83afa8

Browse files
DavideDSanne
authored andcommitted
OGM-1269 Throw exception when cache configuration is missing
1 parent 8475bb7 commit b83afa8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

infinispan/src/main/java/org/hibernate/ogm/datastore/infinispan/logging/impl/Log.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ public interface Log extends org.hibernate.ogm.util.impl.Log {
4141
@Message(id = 1105, value = "Infinispan Externalizer mistmatch: id [%1$d] was registered but taken " +
4242
"by implementation '%2$s'. Expected externalizer: '%3$s' ")
4343
HibernateException externalizerIdNotMatchingType(Integer externalizerId, AdvancedExternalizer<?> registeredExternalizer, AdvancedExternalizer expectedExternalizer);
44+
45+
@Message(id = 1106, value = "Missing configuration for cache '%1$s' and a default configuration was not provided")
46+
Exception missingCacheConfiguration(String cacheName);
4447
}

infinispan/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/LocalCacheManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.hibernate.HibernateException;
1818
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
1919
import org.hibernate.ogm.datastore.infinispan.impl.TransactionManagerLookupDelegator;
20+
import org.hibernate.ogm.datastore.infinispan.logging.impl.Log;
21+
import org.hibernate.ogm.datastore.infinispan.logging.impl.LoggerFactory;
2022
import org.hibernate.ogm.model.key.spi.AssociationKeyMetadata;
2123
import org.hibernate.ogm.model.key.spi.EntityKeyMetadata;
2224
import org.hibernate.ogm.model.key.spi.IdSourceKeyMetadata;
@@ -51,6 +53,8 @@
5153
*/
5254
public abstract class LocalCacheManager<EK, AK, ISK> {
5355

56+
private static final Log LOG = LoggerFactory.getLogger();
57+
5458
private final EmbeddedCacheManager cacheManager;
5559
private final boolean isProvidedCacheManager;
5660

@@ -94,6 +98,9 @@ private static EmbeddedCacheManager createCustomCacheManager(URL configUrl, JtaP
9498
if ( originalCfg == null ) {
9599
originalCfg = tmpCacheManager.getDefaultCacheConfiguration();
96100
}
101+
if ( originalCfg == null ) {
102+
throw LOG.missingCacheConfiguration( cacheName );
103+
}
97104
Configuration newCfg;
98105
if ( originalCfg.transaction().transactionMode() == TransactionMode.TRANSACTIONAL ) {
99106
//Inject our TransactionManager lookup delegate for transactional caches ONLY!

0 commit comments

Comments
 (0)