Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
ConfigurationClassEnhancer.enhanceFactoryBean is not transparent for method calls other than getObject() [SPR-12915] #17514
The relevant code reads:
In the marked line, obj refers to the proxy object.
Therefore, calls to methods other than getObject() are forwarded to the super implementation on the proxy object, which has a different state than the FactoryBean it proxies.
This breaks the following usecase:
where DBTool has a method:
which now throws
because the proxy object is a factory that has not been configured.
Adrian Moos commented
As a workaround, the
Juergen Hoeller commented
Due to the implications reported in #17686, I'll reduce this change to the 4.2 line.
Modifying the CGLIB proxy to delegate all calls is surprisingly non-trivial, in particular for cross-method calls within the same instance. We might even have to create such FactoryBean proxy instances via Objenesis, just like we do for AOP proxies. For that reason, this definitely has to go through another RC and is therefore better suited for the 4.2 line.