Spring logs FactoryBean type check warning in case of factory method with arguments [SPR-12900] #17499
I have two configuration files:
Here MIHessianProxyFactory extends com.caucho.hessian.client.HessianProxyFactory
When i run my application Spring tries to create deviceServiceHessianProxyFactoryBean.
It goes to AbstractAutowireCapableBeanFactory#getSingletonFactoryBeanForTypeCheck and execute method #beforeSingletonCreation.
In #beforeSingletonCreation method it puts bean name "deviceServiceHessianProxyFactoryBean" in singletonsCurrentlyInCreation List.
Than it goes to AbstractAutowireCapableBeanFactory#createBeanInstance() method and tries to create deviceServiceHessianProxyFactoryBean bean.
But inside #createBeanInstance() method Srping calls #beforeSingletonCreation() method one more time and it throws BeanCurrentlyInCreationException because it was already called for this bean.
Of cause it is correct situation if i have circular dependencies but there are no circular dependencies in my config.
There are two stack traces below. See comments in both stack traces.
Juergen Hoeller commented
This is in fact working as designed: When trying to resolve the argument for your factory method, Spring's type matching algorithm is also checking the FactoryBean that you're currently creating there - and fails since it is currently in creation - a kind of circular reference with the currently created FactoryBean when trying to check its type. The FactoryBean check then backs out and considers this self-reference a non-match.
That said, the primary problem seems to be that we're logging a warning in case of such FactoryBean type resolution failure. I'll lower this to debug for the currently-in-creation case, just logging a warning for a 'real' resolution problem (typically an invalid FactoryBean definition).