-
Notifications
You must be signed in to change notification settings - Fork 38.5k
@AliasFor is needed on all attributes (even if they have the same name as the "parent") [SPR-13554] #18130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sam Brannen commented Dave Syer, thanks for raising the issue. I'll look into it. If you could provide a small example that reproduces the issue (or at least sketch out the failing scenario), that would be very helpful. Cheers, Sam |
Sam Brannen commented In the interim, without further input, I have done my best to recreate the scenario that (I believe) you are describing. Specifically, in the following
@ContextConfig
@Retention(RetentionPolicy.RUNTIME)
@interface HalfConventionBasedAndHalfAliasedComposedContextConfig {
String[] locations() default {};
@AliasFor(annotation = ContextConfig.class, attribute = "locations")
String[] xmlConfigFiles() default {};
} Dave Syer, can you please confirm that the test introduced in GitHub commit 5e1d6e4 reflects the scenario you encountered? Thanks! Sam |
Dave Syer commented Yes, that looks similar at least (you are talking about |
Sam Brannen commented
Ahhhh, well... this is not a bug. Rather, this is a known limitation of convention-based attribute overrides: the The following snippet from // Implicit annotation attribute override based on convention
else if (!AnnotationUtils.VALUE.equals(attributeName) && attributes.containsKey(attributeName)) {
overrideAttribute(element, annotation, attributes, attributeName, attributeName);
} One of the primary reasons for this is the fact that component stereotypes (e.g., |
Sam Brannen commented The aforementioned Since Spring does not support such a hybrid approach for annotation attribute overrides with transitive implicit aliases, I am resolving this issue as Works as Designed. Rationale: the main problem with convention based overrides is that they are ambiguous: it is unclear for which meta-annotation the override is intended and therefore impossible to know upfront if convention-based attribute overrides should be considered as transitive implicit aliases for other local attributes. These issues can only be reliably addressed by explicit use of |
Dave Syer opened SPR-13554 and commented
From a comment in #18028. "The custom annotation has to use
@AliasFor
on all its inherited attributes for this to work." (And Sam said: "Are you saying that convention-based attribute overrides do not work? If so, then that's a bug, and please report it.")Affects: 4.2.1
Issue Links:
Referenced from: commits 6826bdd, 5e1d6e4
The text was updated successfully, but these errors were encountered: