Skip to content

Commit 8e14520

Browse files
committed
Merge from sbrannen/SPR-13405
* SPR-13405: Support transitive implicit attribute aliases with @AliasFor
2 parents d899efd + 2a6716d commit 8e14520

File tree

4 files changed

+322
-146
lines changed

4 files changed

+322
-146
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -956,21 +956,14 @@ public void postProcess(AnnotatedElement element, Annotation annotation, Annotat
956956

957957
for (Method attributeMethod : AnnotationUtils.getAttributeMethods(annotation.annotationType())) {
958958
String attributeName = attributeMethod.getName();
959-
List<String> aliases = AnnotationUtils.getAliasedAttributeNames(attributeMethod, targetAnnotationType);
959+
String attributeOverrideName = AnnotationUtils.getAttributeOverrideName(attributeMethod, targetAnnotationType);
960960

961961
// Explicit annotation attribute override declared via @AliasFor
962-
if (!aliases.isEmpty()) {
963-
if (aliases.size() != 1) {
964-
throw new IllegalStateException(String.format(
965-
"Alias list for annotation attribute [%s] must contain at most one element: %s",
966-
attributeMethod, aliases));
967-
}
968-
String aliasedAttributeName = aliases.get(0);
969-
if (attributes.containsKey(aliasedAttributeName)) {
970-
overrideAttribute(element, annotation, attributes, attributeName, aliasedAttributeName);
962+
if (attributeOverrideName != null) {
963+
if (attributes.containsKey(attributeOverrideName)) {
964+
overrideAttribute(element, annotation, attributes, attributeName, attributeOverrideName);
971965
}
972966
}
973-
974967
// Implicit annotation attribute override based on convention
975968
else if (!AnnotationUtils.VALUE.equals(attributeName) && attributes.containsKey(attributeName)) {
976969
overrideAttribute(element, annotation, attributes, attributeName, attributeName);

0 commit comments

Comments
 (0)