Hmm, you should actually get a circularity error, since a reference b,
and b references a.
If you are not, then _that's_ what I would consider a bug.
Colin
-------- Original Message --------
Subject: [Springframework-developer] Possible bug in Spring
Date: Thu, 15 Jul 2004 16:18:53 -0700
From: Andy Depue <an...@ma...>
Reply-To: spr...@li...
Organization: Marathon Computer Systems
To: <spr...@li...>
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
|