|
From: Andy D. <an...@ma...> - 2004-07-15 23:18:58
|
I may have discovered a bug in Spring, but I want to make sure it is not
already known (and that it is really a bug).
Say you have these beans defined:
----
<bean id="a" class="mypackage.A">
<property name="b"><ref bean="b"/></property>
</bean>
<bean id="b" class="mypackage.B">
<constructor-arg index="0"><ref bean="a"/></constructor-arg>
</bean>
<bean id="c" class="mypackage.C">
<property name="b"><ref bean="b"/></property>
</bean>
----
If you write the code below, you get "different instances":
A a = (A)ac.getBean("a");
C c = (C)ac.getBean("c");
if(a.getB() != c.getB()) {
System.out.println("different instances");
}
---
Basically, bean "b" is instantiated twice, even though it is a singleton. At
the very least, I would want to have an exception thrown rather than Spring
silently creating two instances of "b". I should note that this is against a
version of spring that was obtained from cvs about 3 weeks ago. I currently
do not have time to test against a newer Spring, but thought I'd put this out
there anyway so that if it is known, then I won't spend any more time on the
problem.
Thanks,
Andy
|