Results 1 to 4 of 4

Thread: Recursion during bean creation

  1. #1
    Join Date
    Aug 2004
    Posts
    230

    Default Recursion during bean creation

    It will take a bit of work to produce a standalone test for this, so I would like to describe it here first.

    JC is in the process of creating a bean and goes recursive. Here's the synopsis:

    - Way down the stack, "AbstractBeanFactory.getBean(String, Class)#line_168" is executing
    - "CglibConfigurationEnhancer.BeanMethodInterceptor. doIntercept#line_306" is inside the "if(factoryContainsBean(beanName))" if-block
    - "beanFactory.getBean(beanName)" is invoked, since JC sees that the bean creation is in progress
    - Now we go to "DefaultJavaConfigBeanFactory extends AbstractBeanFactory.getBean(String)#line 164"
    - which ultimately leads back to the first method listed above

    Because of some poor legacy code that I'm trying to work thru, I have lots of code that does not inject beans, but rather pulls them from a BeanFactory. In this case, a ClassPathXmlApplicationContext is created (which contains the JC context that I have just recently added) but only the result of "ClassPathXmlApplicationContext.getBeanFactory ()" is saved from which the application extracts its beans. Since this is very non-typical, it could well be an edge case for JC.
    Barry Kaplan (memelet)

  2. #2
    Join Date
    Aug 2004
    Posts
    230

    Default

    BTW, I can get around this recursion by changing bean creation from:

    - beanFactory.getBean(name, type)

    To

    - TypeSafeBeanFactoryUtils.getBean((ListableBeanFact ory) beanFactory, type, name);
    Barry Kaplan (memelet)

  3. #3
    Join Date
    Apr 2007
    Posts
    307

    Default

    Barry,

    Certainly sounds like it may be an issue. I won't have much time to attempt to reproduce it myself this week (SpringOne Americas has got me plenty busy!). So, if you can put together a test case that reproduces the issue, please do so and attach it to a new JIRA issue. If you can get it that far, I should be able to carve some time out to give it a look in pretty short order.
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

  4. #4
    Join Date
    Aug 2004
    Posts
    230

    Default

    I'll try to do that. But I have already made lots of simplifications and no longer hit the problem, so its not gonna be high on my priority list either.

    Have fun at SpringOne -- I'm gonna miss it this year.
    Barry Kaplan (memelet)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •