Improve performance of generateKey
Only compute the error message to display when the generated key is actually null instead of using Assert.notNull as the cache operation 'toString()' method is non trivial and gets computed regardless of the result. Issue: SPR-12527
This commit is contained in:
parent
b0a72b311f
commit
67f184293b
|
@ -477,8 +477,10 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
|
|||
|
||||
private Object generateKey(CacheOperationContext context, Object result) {
|
||||
Object key = context.generateKey(result);
|
||||
Assert.notNull(key, "Null key returned for cache operation (maybe you are using named params " +
|
||||
"on classes without debug info?) " + context.metadata.operation);
|
||||
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);
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Computed cache key " + key + " for operation " + context.metadata.operation);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue