Skip to content

Commit a83b08a

Browse files
committed
improve format of second-level cache log messages
1 parent 1405fb1 commit a83b08a

File tree

5 files changed

+19
-26
lines changed

5 files changed

+19
-26
lines changed

hibernate-core/src/main/java/org/hibernate/cache/spi/SecondLevelCacheLogger.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package org.hibernate.cache.spi;
66

77
import org.hibernate.internal.log.SubSystemLogging;
8-
import org.hibernate.metamodel.model.domain.NavigableRole;
98

109
import org.jboss.logging.BasicLogger;
1110
import org.jboss.logging.Logger;
@@ -37,15 +36,15 @@ public interface SecondLevelCacheLogger extends BasicLogger {
3736

3837
@LogMessage(level = WARN)
3938
@Message(
40-
value = "Attempt to restart an already started RegionFactory. Use sessionFactory.close() between " +
41-
"repeated calls to buildSessionFactory. Using previously created RegionFactory.",
39+
value = "Attempt to start an already-started RegionFactory, probably because a SessionFactory was not closed." +
40+
" Using previously created RegionFactory.",
4241
id = NAMESPACE + 1
4342
)
4443
void attemptToStartAlreadyStartedCacheProvider();
4544

4645
@LogMessage(level = WARN)
4746
@Message(
48-
value = "Attempt to restop an already stopped JCacheRegionFactory.",
47+
value = "Attempt to stop an already-stopped JCacheRegionFactory.",
4948
id = NAMESPACE + 2
5049
)
5150
void attemptToStopAlreadyStoppedCacheProvider();
@@ -55,33 +54,27 @@ public interface SecondLevelCacheLogger extends BasicLogger {
5554
value = "Read-only caching was requested for mutable entity [%s]",
5655
id = NAMESPACE + 3
5756
)
58-
void readOnlyCachingMutableEntity(NavigableRole navigableRole);
57+
void readOnlyCachingMutableEntity(String entity);
5958

6059
@LogMessage( level = WARN )
6160
@Message(
6261
value = "Read-only caching was requested for mutable natural-id for entity [%s]",
6362
id = NAMESPACE + 4
6463
)
65-
void readOnlyCachingMutableNaturalId(NavigableRole navigableRole);
64+
void readOnlyCachingMutableNaturalId(String entity);
6665

67-
/**
68-
* Log a message (WARN) about expiry of soft-locked region.
69-
*/
7066
@LogMessage(level = INFO)
7167
@Message(
72-
value = "Cache[%s] Key[%s]\n" +
73-
"A soft-locked cache entry was expired by the underlying cache. If this happens regularly you " +
74-
"should consider increasing the cache timeouts and/or capacity limits",
68+
value = "A soft-locked cache entry in region [%s] with key [%s] was expired by the underlying cache." +
69+
" If this happens regularly, consider increasing the cache timeouts and/or capacity limits.",
7570
id = NAMESPACE + 5
7671
)
7772
void softLockedCacheExpired(String regionName, Object key);
7873

7974
@LogMessage(level = WARN)
8075
@Message(
81-
value = "Missing cache[%1$s] was created on-the-fly." +
82-
" The created cache will use a provider-specific default configuration:" +
83-
" make sure you defined one." +
84-
" You can disable this warning by setting '%2$s' to '%3$s'.",
76+
value = "Missing cache region [%1$s] was created with provider-specific default policies." +
77+
" Explicitly configure the region and its policies, or disable this warning by setting '%2$s' to '%3$s'.",
8578
id = NAMESPACE + 6
8679
)
8780
@SuppressWarnings( "unused" ) // used by hibernate-jcache
@@ -90,19 +83,19 @@ public interface SecondLevelCacheLogger extends BasicLogger {
9083
@LogMessage(level = WARN)
9184
@Message(
9285
value = "Using legacy cache name [%2$s] because configuration could not be found for cache [%1$s]." +
93-
" Update your configuration to rename cache [%2$s] to [%1$s].",
86+
" Update configuration to rename cache [%2$s] to [%1$s].",
9487
id = NAMESPACE + 7
9588
)
9689
@SuppressWarnings( "unused" ) // used by hibernate-jcache
9790
void usingLegacyCacheName(String currentName, String legacyName);
9891

9992
@LogMessage(level = WARN)
10093
@Message(
101-
value = "Cache [%1$s] uses the [%2$s] access type, but [%3$s] does not support it natively." +
102-
" Make sure your cache implementation supports JTA transactions.",
94+
value = "Cache region [%1$s] has the access type '%2$s' which is not supported by [%3$s]." +
95+
" Ensure cache implementation supports JTA transactions.",
10396
id = NAMESPACE + 8
10497
)
10598
@SuppressWarnings( "unused" ) // used by hibernate-jcache
106-
void nonStandardSupportForAccessType(String key, String accessType, String regionName);
99+
void nonStandardSupportForAccessType(String regionName, String accessType, String regionFactoryClass);
107100

108101
}

hibernate-core/src/main/java/org/hibernate/cache/spi/support/EntityReadOnlyAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public EntityReadOnlyAccess(
3131
EntityDataCachingConfig config) {
3232
super( region, cacheKeysFactory, storageAccess );
3333
if ( config.isMutable() ) {
34-
L2CACHE_LOGGER.readOnlyCachingMutableEntity( config.getNavigableRole() );
34+
L2CACHE_LOGGER.readOnlyCachingMutableEntity( config.getNavigableRole().getFullPath() );
3535
}
3636
}
3737

hibernate-core/src/main/java/org/hibernate/cache/spi/support/NaturalIdReadOnlyAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public NaturalIdReadOnlyAccess(
2727
NaturalIdDataCachingConfig config) {
2828
super( region, keysFactory, storageAccess, config );
2929
if ( config.isMutable() ) {
30-
L2CACHE_LOGGER.readOnlyCachingMutableNaturalId( config.getNavigableRole() );
30+
L2CACHE_LOGGER.readOnlyCachingMutableNaturalId( config.getNavigableRole().getFullPath() );
3131
}
3232
}
3333

hibernate-core/src/main/java/org/hibernate/resource/beans/internal/BeansMessageLogger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@ValidIdRange( min = 10005001, max = 10010000 )
2727
@SubSystemLogging(
2828
name = BeansMessageLogger.LOGGER_NAME,
29-
description = "Logging related to Hibernate's support for managed beans (CDI, etc)"
29+
description = "Logging related to managed beans and the BeanContainer (CDI, etc)"
3030
)
3131
public interface BeansMessageLogger {
3232
String LOGGER_NAME = SubSystemLogging.BASE + ".beans";
@@ -37,8 +37,8 @@ public interface BeansMessageLogger {
3737
@Message(
3838
id = 10005001,
3939
value = "An explicit CDI BeanManager reference [%s] was passed to Hibernate, " +
40-
"but CDI is not available on the Hibernate ClassLoader. This is likely " +
41-
"going to lead to exceptions later on in bootstrap"
40+
"but CDI is not available on the Hibernate ClassLoader. This is likely " +
41+
"going to lead to exceptions later on in bootstrap."
4242
)
4343
void beanManagerButCdiNotAvailable(Object cdiBeanManagerReference);
4444

hibernate-jcache/src/test/java/org/hibernate/orm/test/jcache/MissingCacheStrategyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private void doTestMissingCacheStrategyCreateWarn(Consumer<StandardServiceRegist
106106
triggerables.put(
107107
regionName,
108108
logInspection.watchForLogMessages(
109-
"HHH90001006: Missing cache[" + TestHelper.prefix( regionName ) + "] was created on-the-fly"
109+
"HHH90001006: Missing cache region [" + TestHelper.prefix( regionName ) + "] was created"
110110
)
111111
);
112112
}

0 commit comments

Comments
 (0)