Skip to content
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

Meta-@Conditional lookup does not work consistently with ASM [SPR-14257] #18829

Closed
spring-projects-issues opened this issue May 6, 2016 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 6, 2016

Andy Wilkinson opened SPR-14257 and commented

When ConditionEvaluator looks for Conditional annotations, it doesn't find them when they are a meta-meta-annotation. The problem appears to be due to ConditionEvaluator's use of AnnotationTypeMetadata.getAllAnnotationAttributes which doesn't return all of the values for all of the Conditional annotations that are present. The attached class should hopefully illustrate the behaviour that we're seeing. When run it should output:

com.example.ConditionComposition$MetaFooAndBarConfiguration [class com.example.ConditionComposition$ConditionalOnBar$BarEnabledCondition]
com.example.ConditionComposition$MetaFooAndMetaBarConfiguration []
com.example.ConditionComposition$ExplicitAnnotationConfiguration [class com.example.ConditionComposition$ConditionalOnFoo$FooEnabledCondition, class com.example.ConditionComposition$ConditionalOnBar$BarEnabledCondition]

My expectation is that all three configuration classes should produce the output that ExplicitAnnotationConfiguration produces.


Affects: 4.2.6

Attachments:

Issue Links:

Referenced from: commits 24f5f36, 7de2976

Backported to: 4.2.7

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This seems to be an inconsistency between reflection-based and ASM-based lookup: with the latter, AnnotationMetadataReadingVisitor seems to be limited to one meta-annotation level in terms of attribute retrieval. We need to allow for attribute lookups across arbitrary meta-annotation levels there, just like StandardAnnotationMetadata does.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've addressed two related issues:

ASM's meta-annotation scanning was tracking visited annotations by annotation type name, therefore not reliably detecting multiple occurences of the same annotation.

Also, we did not traverse to meta-meta-annotations for non-public meta annotations due to fear of illegal access exceptions. This seems to primarily affect attribute retrieval though, not meta-annotation introspection. To be on the safe side, we're guarding against introspection failures through a catch block now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants