Expand var-args before passing to KeyGenerator
Update `CacheAspectSupport` to expand any var-arg parameters before calling `KeyGenerator` implementations. Prior to this commit var-args would be passed to `KeyGenerator` implementations as a nested array, often causing the same key to be generated regardless of the arguments. Issue: SPR-10870
This commit is contained in:
@@ -87,6 +87,12 @@ public class AnnotatedClassCacheableService implements CacheableService<Object>
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "default")
|
||||
public Object varArgsKey(Object... args) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "default", key = "#root.methodName + #root.caches[0].name")
|
||||
public Object name(Object arg1) {
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface CacheableService<T> {
|
||||
|
||||
T key(Object arg1, Object arg2);
|
||||
|
||||
T varArgsKey(Object... args);
|
||||
|
||||
T name(Object arg1);
|
||||
|
||||
T nullValue(Object arg1);
|
||||
|
||||
@@ -91,6 +91,12 @@ public class DefaultCacheableService implements CacheableService<Long> {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "default")
|
||||
public Long varArgsKey(Object... args) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "default", key = "#root.methodName")
|
||||
public Long name(Object arg1) {
|
||||
|
||||
Reference in New Issue
Block a user