Skip to content

Fix @Bean meta-annotation detection when using ASM [SPR-10488] #15121

Closed
@spring-projects-issues

Description

@spring-projects-issues

Didier Villevalois opened SPR-10488 and commented

When using @Bean as meta-annotation, Configuration class enhancement correctly takes the meta-annotated methods, but ConfigurationClassParser does not correctly registers @Bean methods.

This comes from MethodMetadataReadingVisitor.visitAnnotation() :

@Override
public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
	String className = Type.getType(desc).getClassName();
	methodMetadataMap.add(className, this);
	return new AnnotationAttributesReadingVisitor(className, this.attributeMap, null, this.classLoader);
}

Here a null metaAnnotationMap argument is passed to AnnotationAttributesReadingvisitor. I guess more things should be added to methodMetadataMap.

As a result, in ConfigurationClassParser:247 :

// process individual @Bean methods
Set<MethodMetadata> beanMethods = metadata.getAnnotatedMethods(Bean.class.getName());
for (MethodMetadata methodMetadata : beanMethods) {
	configClass.addBeanMethod(new BeanMethod(methodMetadata, configClass));
}

getAnnotatedMethods() does not return methods meta-annotated with @Bean.

Do you need a test case ? Or is this easy enough to reproduce ?


Affects: 3.2.2

Backported to: 3.2.7

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions