|
28 | 28 | import java.util.List;
|
29 | 29 | import java.util.Map;
|
30 | 30 | import java.util.Set;
|
| 31 | +import java.util.concurrent.ConcurrentHashMap; |
| 32 | + |
| 33 | +import org.apache.commons.logging.Log; |
| 34 | +import org.apache.commons.logging.LogFactory; |
31 | 35 |
|
32 | 36 | import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet;
|
33 | 37 | import org.springframework.lang.Nullable;
|
|
46 | 50 | */
|
47 | 51 | final class AnnotationTypeMapping {
|
48 | 52 |
|
| 53 | + private static final Log logger = LogFactory.getLog(AnnotationTypeMapping.class); |
| 54 | + |
| 55 | + /** |
| 56 | + * Set of fully qualified class names concatenated with attribute names for |
| 57 | + * annotations which we have already checked for use of convention-based |
| 58 | + * annotation attribute overrides. |
| 59 | + * @since 6.0 |
| 60 | + * @see #addConventionMappings() |
| 61 | + */ |
| 62 | + private static final Set<String> conventionBasedOverrideCheckCache = ConcurrentHashMap.newKeySet(); |
| 63 | + |
49 | 64 | private static final MirrorSet[] EMPTY_MIRROR_SETS = new MirrorSet[0];
|
50 | 65 |
|
51 | 66 |
|
@@ -273,6 +288,21 @@ private void addConventionMappings() {
|
273 | 288 | String name = this.attributes.get(i).getName();
|
274 | 289 | int mapped = rootAttributes.indexOf(name);
|
275 | 290 | if (!MergedAnnotation.VALUE.equals(name) && mapped != -1 && !isExplicitAttributeOverride(name)) {
|
| 291 | + String rootAnnotationTypeName = this.root.annotationType.getName(); |
| 292 | + // We want to avoid duplicate log warnings as much as possible, without |
| 293 | + // fully synchronizing on the cache. |
| 294 | + String cacheKey = rootAnnotationTypeName + "." + name; |
| 295 | + if (!conventionBasedOverrideCheckCache.contains(cacheKey)) { |
| 296 | + conventionBasedOverrideCheckCache.add(cacheKey); |
| 297 | + if (logger.isWarnEnabled()) { |
| 298 | + logger.warn(""" |
| 299 | + Support for convention-based annotation attribute overrides is \ |
| 300 | + deprecated and will be removed in Spring Framework 6.1. Please \ |
| 301 | + annotate the '%s' attribute in @%s with an appropriate @AliasFor \ |
| 302 | + declaration.""" |
| 303 | + .formatted(name, rootAnnotationTypeName)); |
| 304 | + } |
| 305 | + } |
276 | 306 | mappings[i] = mapped;
|
277 | 307 | MirrorSet mirrors = getMirrorSets().getAssigned(i);
|
278 | 308 | if (mirrors != null) {
|
|
0 commit comments