Skip to content

Prevent duplicate @Import processing and ImportBeanDefinitionRegistrar invocation [SPR-9925] #14558

@spring-projects-issues

Description

@spring-projects-issues

Oliver Drotbohm opened SPR-9925 and commented

When implementing custom @Enable annotations using ImportBeanDefinitionRegistrar instances, the implementation gets called twice. Chris and I could debug this down into ConfigurationClassParser.findAllAnnotationAttributes(…) where the config class is scanned for annotation attributes. It does an explicit check against meta-annotation attributes (explicitly excluding the annotation type while iterating over the local annotations) and against local annotation attributes right after that.

The crucial issue here is that the local attribute metadata inspected already contains the entire attribute hierarchy. Seems like it has already been resolved against meta annotations at that place. The net effect is that the @Import annotation is found twice - first, through the explicit meta-annotation lookup in my @Enable annotation and second during inspecting the local attributes.

We essentially have to decide to drop the explicit meta-annotation lookup as we seem to be able to find all necessary information through the local scanning already. The other option is to let the attributes only contain local attributes in the first place but this probably has wider implications.


Affects: 3.1.2, 3.2 M2

Sub-tasks:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions