You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the most post, transitive implicit aliases for annotation attribute overrides configured via @AliasFor work. However, I have detected a corner case that fails.
Failing Example
Given the following three annotations, if an attempt is made to look up a merged@ContextConfig annotation via AnnotatedElementUtils (e.g., using getMergedAnnotation() or findMergedAnnotation()) on an element annotated with @TransitiveImplicitAliasesContextConfig then the look up will fail with an AnnotationConfigurationException stating something similar to the following:
attribute 'value' and its alias 'locations' are declared with values of [{}] and [{test.groovy}], but only one is permitted.
If the value attribute in ImplicitAliasesContextConfig declares attribute = "locations" via @AliasFor, the code then works as expected. Thus, there is obviously a bug in the lookup mechanism for names of overridden attributes in conjunction with transitive implicit aliases.
Ensure all aliased attributes in target annotation are overridden
Prior to this commit, it was possible that implicit aliases and
transitive implicit aliases (configured via @AliasFor) might not be
honored in certain circumstances, in particular if implicit aliases
were declared to override different attributes within an alias pair in
the target meta-annotation.
This commit addresses this issue by ensuring that all aliased
attributes in the target meta-annotation are overridden during the
merge process in AnnotatedElementUtils.
In addition, concrete default values for attributes in a
meta-annotation declaration can now be effectively shadowed by
transitive implicit aliases in composed annotations.
Sam Brannen opened SPR-14069 and commented
Status Quo
For the most post, transitive implicit aliases for annotation attribute overrides configured via
@AliasFor
work. However, I have detected a corner case that fails.Failing Example
Given the following three annotations, if an attempt is made to look up a merged
@ContextConfig
annotation viaAnnotatedElementUtils
(e.g., usinggetMergedAnnotation()
orfindMergedAnnotation()
) on an element annotated with@TransitiveImplicitAliasesContextConfig
then the look up will fail with anAnnotationConfigurationException
stating something similar to the following:If the
value
attribute inImplicitAliasesContextConfig
declaresattribute = "locations"
via@AliasFor
, the code then works as expected. Thus, there is obviously a bug in the lookup mechanism for names of overridden attributes in conjunction with transitive implicit aliases.Deliverables
TODO
inAnnotatedElementUtilsTests
.Affects: 4.2.2
Referenced from: commits d22480b, 2153d88
The text was updated successfully, but these errors were encountered: