commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "krishna patury (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (LANG-69) [lang] ToStringBuilder throws StackOverflowError when an Object cycle exists
Date Fri, 04 Jan 2008 20:30:34 GMT

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

kppatury edited comment on LANG-69 at 1/4/08 12:29 PM:
-------------------------------------------------------------

Hello,
Has anyone seen the StackOverflowError occur in version2.3 for the use of ReflectionToStringBuilder?

We have the following code using it in our application and it works fine in version 2.0. But
when we upgrade to version 2.3 we are seeing a StackOverflowError . Cannot think of any other
recursive calls which might cause this..
------------------------------------------------------------------------------------
public String toString() {
    return ReflectionToStringBuilder.toString(this);
}
------------------------------------------------------------------------------------
Any advise would be helpful..Thanks!

      was (Author: kppatury):
    Hello,
Has anyone seen the StackOverflowError occur in version2.3 for the use of RefelctionToStringBuilder?

We have the following code using it in our application and it works fine in version 2.0. But
when we upgrade to version 2.3 we are seeing a StackOverflowError . Cannot think of any other
recursive calls which might cause this..
------------------------------------------------------------------------------------
public String toString() {
    return ReflectionToStringBuilder.toString(this);
}
------------------------------------------------------------------------------------
Any advise would be helpful..Thanks!
  
> [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