XStream
  1. XStream
  2. XSTR-94

StringBuffer does not use references

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1
    • Component/s: Converters
    • Labels:
      None

      Description

      From: Heiner Schwarte

      In the following code sniplet, references to a single StringBuffer object are
      serialised as separate objects. (xstream-1.0.1.jar, IBMJava2-141, Eclipse
      3.0.0)

      Regards Heiner

      public class Test {
      public static void main(String[] args)

      { XStream xstream = new XStream(); StringBuffer str1= new StringBuffer("Hello"); StringBuffer str2 = str1; str2.setCharAt(1,'a'); Pair p=new Pair(str1,str2); // Pair has two Object slots named first and second String out=xstream.toXML(p); System.out.println(out); Pair p2=(Pair)xstream.fromXML(out); ((StringBuffer) p2.first).setCharAt(1,'e'); System.out.println((StringBuffer)(p2.second)); //should be "Hello", not "Hallo" }

      }

        People

        • Assignee:
          Unassigned
          Reporter:
          Joe Walnes
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: