You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ro...@Toyota.com on 2004/03/25 01:25:21 UTC

Question about ToStringStyle.appendInternal() method

Hi,

I was trying to figure out an infinate loop problem when I am printing out 
an object. I have an object 'a' of class 'A' which has a collection of 
object 'b' of class 'B', and 'B' has a reference back to 'A'. The 
toString() method of both 'A' and 'B' contains each other. When I tried to 
print 'a' out, I got into an infinate loop.

>From looking at the source code of ToStringStyle.java, it appears to me 
that its appendInternal() method never registers the object to be printed 
to the registry. Therefore, the if check on the first line of this method 
"if (ReflectionToStringBuilder.isRegistered(value)" always returns false, 
and thus result in an infinate loop.

Please let me know if this is the case. Thanks.

Roy