XStream
  1. XStream
  2. XSTR-360

When initializing new Objects from XML, XStream overwrites int fields' default values when no values set in XML.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I have a class with default values set for fields (ints, Strings). I'm hoping that XStream would set only those fields which are defined in the XML.

      When I load the XML, at least ints are set to 0 instead of their default value (-1). I haven't tested other primitives. Here's a small example of what happens now:

      Class A:
      // omitting getters/setters
      class A {
      private int threshold=-1;
      String pattern=null;
      }

      XML
      <a />

      Loading with fromXML:

      A a = (a)xstream.fromXML(xml);

      Result:
      a.threshold = 0 // should be -1
      a.pattern = null // null is ok

      I'm using XStream 1.2 with the DomDriver

        People

        • Assignee:
          Unassigned
          Reporter:
          Mikko Apo
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: