Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-93

StackOverflow due to ToStringBuilder

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.0
    • None
    • None
    • Operating System: other
      Platform: Other

    • 16676

    Description

      The ToStringBuilder doesn't handle relations to other objects
      very well. It's very easy to get into an never-ending-loop.
      The following code will crash the JVM with a StackOverflowError :

      import org.apache.commons.lang.builder.ToStringBuilder;

      public class Test1
      {
      Test1 test;

      public Test1() {}

      public void setTest(Test1 test)

      { this.test = test; }

      public String toString()

      { return ToStringBuilder.reflectionToString(this); }

      public static void main(String[] args)

      { Test1 test1; Test1 test2; test1 = new Test1(); test2 = new Test1(); test1.setTest(test2); test2.setTest(test1); System.out.println(test1.toString()); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            keeskuip@technologist.com Kees Kuip
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: