-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Description
Oliver Drotbohm opened SPR-11251 and commented
If you have an @Enable…
annotation, itself not being annotated with @Inherited
, the related ImportBeanDefinitionRegistrar
is still invoked multiple times when used in inheritance scenarios for configuration classes.
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Import(SomeImporBeanDefinitionRegistrar.class)
public @interface MyAnnotation {
}
@Configuration
@MyAnnotation
public class Config {}
@Configuration
public class SubConfig {}
new AnnotationConfigApplicationContext(SubConfig.class);
Here are the erroneous effects:
- The
ImportBeanDefinitionRegistrar
gets invoked for the leaf class (SubConfig
of the inheritance hierarchy (not the one the annotation is on) - The
AnnotationMetadata
does then returnnull
if you're trying to access the annotation attributes of the triggering annotation.
I've prepared more code samples and the log output for the invocations in this Gist. Spring 4 seems to handle this correct already.
Affects: 3.2.6
Issue Links:
- DATAREST-210 ApplicationContext fails to load with HAL enabled snapshot
- @EnableTransactionManagement and co should also get detected on superclasses [SPR-10864] #15491
@EnableTransactionManagement
and co should also get detected on superclasses - Prevent duplicate @Import processing and ImportBeanDefinitionRegistrar invocation [SPR-9925] #14558 Prevent duplicate
@Import
processing and ImportBeanDefinitionRegistrar invocation - SEC-2425 Support EnableGlobalMethodSecurity on superclass
- Backport fix for multiple invocations of ImportBeanDefinitionRegistrars [SPR-9939] #14572 Backport fix for multiple invocations of ImportBeanDefinitionRegistrars
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug