Document need for -parameters flag in cache key generation exception messages

Closes gh-31675
This commit is contained in:
Sam Brannen
2023-11-30 17:51:46 +01:00
parent edfe179291
commit 33af98b6d6

View File

@@ -670,8 +670,10 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
private Object generateKey(CacheOperationContext context, @Nullable Object result) {
Object key = context.generateKey(result);
if (key == null) {
throw new IllegalArgumentException("Null key returned for cache operation (maybe you are " +
"using named params on classes without debug info?) " + context.metadata.operation);
throw new IllegalArgumentException("""
Null key returned for cache operation [%s]. If you are using named parameters, \
ensure that the compiler uses the '-parameters' flag."""
.formatted(context.metadata.operation));
}
if (logger.isTraceEnabled()) {
logger.trace("Computed cache key '" + key + "' for operation " + context.metadata.operation);