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

BeanFactory does not return FactoryBeans in case the are looked up by type and type prediction is used

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.0.6, 3.1 GA
    • Fix Version/s: 3.1.1
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Assume the following FactoryBean implementation:

      public MyFactoryBean implements FactoryBean<Object>, AnInterface { ... }
      

      Now assume we have a SmartInstantiationAwareBeanPostProcessor registered that does return an arbitrary different type from a call to predictBeanType(...). If you now call BeanFactory.getBeansOfType(AnInterface.class) the registered bean instance will not be returned as the type check is done against the type the factory produces in the first place. If that fails the actual bean type is checked against the given type if the bean definition is considered a factory bean.

      AbstractBeanFactory.isFactoryBean(...) now inspects the predicted bean type and thus does not consider the bean as factory bean. Shouldn't this method check the actual bean type as well or even instead? The current implementation pretty much disables the bean definition being discovered as factory bean as soon as you predict the bean type.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cbeams Chris Beams
                Reporter:
                olivergierke Oliver Gierke
                Last updater:
                Oliver Gierke
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 13 weeks, 1 day ago