Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10488

Fix @Bean meta-annotation detection when using ASM

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Complete
    • 3.2.2
    • 3.2.7, 4.0.1
    • Core, Core:DI
    • None
    • true

    Description

      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 ?

      Attachments

        Activity

          People

            juergen.hoeller Juergen Hoeller
            ptitjes Didier Villevalois
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              3 years, 38 weeks, 1 day ago