Ensure @AliasFor overrides attribute in correct meta-annotation
Prior to this commit, an explicit override for an attribute in a meta-annotation configured via @AliasFor could potentially result in an incorrect override of an attribute of the same name but in the wrong meta-annotation. This commit fixes the algorithm in getAliasedAttributeName(Method, Class) in AnnotationUtils by ensuring that an explicit attribute override is only applied to the configured target meta-annotation (i.e., configured via the 'annotation' attribute in @AliasFor). Issue: SPR-13325
This commit is contained in:
@@ -1465,6 +1465,11 @@ public abstract class AnnotationUtils {
|
||||
boolean sameTargetDeclared =
|
||||
(sourceAnnotationType.equals(aliasedAnnotationType) || Annotation.class.equals(aliasedAnnotationType));
|
||||
|
||||
// Explicit alias for a different target meta-annotation?
|
||||
if (!searchWithinSameAnnotation && !targetAnnotationType.equals(aliasedAnnotationType)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Wrong search scope?
|
||||
if (searchWithinSameAnnotation && !sameTargetDeclared) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user