commons-issues 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, 05 Jan 2008 06:22:34 GMT

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

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

Hi Krishna,

I doubt you'll see much on a closed ticket - I'd suggest either mailing the user@ list to
see if anyone else has had the problem; or if at all possible it would be great if you could
chop away at your business objects a bit and create a reusable test case.

In either case - please feel free to open a new issue up rather than using the old one.

> [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
>            Assignee: 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.


Mime
View raw message