commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LANG-69) [lang] ToStringBuilder throws StackOverflowError when an Object cycle exists
Date Sat, 27 Jan 2007 07:14:49 GMT

    [ https://issues.apache.org/jira/browse/LANG-69?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12468000
] 

Henri Yandell commented on LANG-69:
-----------------------------------

 svn ci -m "Applying a modified version of Maarten Coene's patch for #LANG-69. All unit tests
pass; opinions would be very welcome though. "              

Sending        src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java
Sending        src/java/org/apache/commons/lang/builder/ToStringStyle.java
Sending        src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java
Transmitting file data ...
Committed revision 500495.

Opinions very desired - I moved Maarten's register in appendStart into the appendClassName
and appendIdentityHashCode and changed appendInternal as I mentioned above. 

> [lang] ToStringBuilder throws StackOverflowError when an Object cycle exists
> ----------------------------------------------------------------------------
>
>                 Key: LANG-69
>                 URL: https://issues.apache.org/jira/browse/LANG-69
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 2.1
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Maarten Coene
>         Assigned To: Gary Gregory
>             Fix For: 2.3
>
>         Attachments: 15938.patch, 36061.patch, LANG-69-refactor.patch, ReflectionToStringBuilder.java.patch,
ToStringBuilderTest.java.patch, ToStringStyle.java.patch
>
>
> Hi,
> The ToStringBuilder throws a StackOverflowError if you have a cycle in the
> object graph. For instance, the following toString() method will cause a
> StackOverflowError:
> public class ObjectCycle {
>     Object obj;
>     	
>     public String toString() {
>         return new ToStringBuilder(this).append(obj).toString();
>     }
> }
> public void testObjectCycle() {
>     ObjectCycle a = new ObjectCycle();
>     ObjectCycle b = new ObjectCycle();
>     a.obj = b;
>     b.obj = a;
>     a.toString();  // ouch: StackOverflowError    	
> }
> I'll submit some patches that fixes this problem...
> regards,
> Maarten

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message