You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Spring 3.0, AutowireUtils.resolveAutowiringValue() has required that all ObjectFactory-implementing classes also implement Serializable. This means that when passing an ObjectFactory to ConfigurableListableBeanFactory.registerResolvableDependency(), this must be Serializable.
This was not the case in 2.5.6, however, and so code written to use this facility will not work in 3.0.x unless Serializable is introduced. This is invasive to the client code, and in many cases is highly inappropriate.
I'm not sure why this check is being made. AutowireUtils is constructing a ObjectFactoryDelegatingInvocationHandler which also implements Serializable, but there doesn't seem to be a reason for this.
In addition, in cases where Objectfactory is used, AutowireUtils requires that the requiredType is an interface. If it is not, it silently fails.
This effectively adds two very right constraints on the resolvable dependencies, constraints not specified in the javadoc for ConfigurableListableBeanFactory.registerResolvableDependency(), and which were not present at all prior to 3.0.x. At the very least, the javadoc should be changed to reflect the constraints, but it would be much preferable to refactor the code to not require them at all.
Good catch! We do want special handling of serializable factory objects there but forgot to handle the non-serializable factory case properly: We simply need to call objectFactory.getObject() directly in that case.
Fixed for 3.0.3. Will be available in tonight's 3.0.3 snapshot - feel free to give it an early try...
Kenny MacLeod opened SPR-7264 and commented
Since Spring 3.0,
AutowireUtils.resolveAutowiringValue()
has required that allObjectFactory
-implementing classes also implementSerializable
. This means that when passing anObjectFactory
toConfigurableListableBeanFactory.registerResolvableDependency()
, this must beSerializable
.This was not the case in 2.5.6, however, and so code written to use this facility will not work in 3.0.x unless
Serializable
is introduced. This is invasive to the client code, and in many cases is highly inappropriate.I'm not sure why this check is being made.
AutowireUtils
is constructing aObjectFactoryDelegatingInvocationHandler
which also implementsSerializable
, but there doesn't seem to be a reason for this.Can this check be removed?
Affects: 3.0 GA, 3.0.1, 3.0.2
Referenced from: commits cc23820
The text was updated successfully, but these errors were encountered: