Allow Cache annotations to not specify any cache name

Since Spring 4.1, a CacheResolver may be configured to customize the way
the cache(s) to use for a given cache operation are retrieved. Since a
CacheResolver implementation may not use the cache names information at
all, this attribute has been made optional.

However, a fix was still applied, preventing a Cache operation without a
cache name to be defined properly. We now allow this valid use case.

Issue: SPR-13081
This commit is contained in:
Stephane Nicoll
2015-06-03 11:42:49 +02:00
parent b5bb26b7c6
commit daf12a9723
3 changed files with 85 additions and 11 deletions

View File

@@ -235,11 +235,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
"default cache resolver if none is set. If a cache resolver is set, the cache manager" +
"won't be used.");
}
if (operation.getCacheNames().isEmpty()) {
throw new IllegalStateException("No cache names could be detected on '" +
ae.toString() + "'. Make sure to set the value parameter on the annotation or " +
"declare a @CacheConfig at the class-level with the default cache name(s) to use.");
}
}
@Override