-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Clancy Kornie opened SPR-10918 and commented
I ran into a situation where classes can be scanned twice. It's quite easy to reproduce.
Given an annotation class:
@Import(TestImport.class)
public @interface AnotherImport {
}
And a configuration class which is annotated with the above:
@Configuration
@AnotherImport
public class TestConfiguration {
}
And the imported class:
public class TestImport implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(@NotNull AnnotationMetadata anImport, @NotNull BeanDefinitionRegistry aRegistry) {
System.out.println("I am scanned twice!");
}
}
You can see that the log message is printed twice. I don't believe this is correct behaviour. After debugging I believe the issue occurs in ConfigurationClassParser.collectImports where the annotation is resolved on AnotherImport as a class and on TestConfiguration as a string. Hence it is placed into the imports HashSet twice. Perhaps we could do the conversion from a String to a class at this stage?
Affects: 3.2.4
Issue Links:
- Filter source @Configuration with @ComponentScan [SPR-10531] #15161 Filter source
@Configuration
with@ComponentScan
- @Import in another annotation still results in double scan [SPR-12334] #16939
@Import
in another annotation still results in double scan
0 votes, 5 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug