Consistent cache key implementation across transaction and cache attribute sources

Includes consistent applicability of class-level metadata to user-level methods only.

Issue: SPR-14017
Issue: SPR-14095
This commit is contained in:
Juergen Hoeller
2016-03-30 14:13:04 +02:00
parent 5619b005f0
commit 14bf6509ec
5 changed files with 135 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.expression.AnnotatedElementKey;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.MethodClassKey;
import org.springframework.util.ClassUtils;
/**
@@ -51,12 +51,12 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
protected final Log logger = LogFactory.getLog(getClass());
private final Map<Object, Object> cache = new ConcurrentHashMap<Object, Object>(1024);
private final Map<MethodClassKey, Object> cache = new ConcurrentHashMap<MethodClassKey, Object>(1024);
@Override
public JCacheOperation<?> getCacheOperation(Method method, Class<?> targetClass) {
Object cacheKey = new AnnotatedElementKey(method, targetClass);
MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
Object cached = this.cache.get(cacheKey);
if (cached != null) {
@@ -95,7 +95,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
return operation;
}
if (specificMethod != method) {
// Fall back is to look at the original method.
// Fallback is to look at the original method.
operation = findCacheOperation(method, targetClass);
if (operation != null) {
return operation;