XStream
  1. XStream
  2. XSTR-204

deserializing Enums incorrectly

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      1.5.1-01 and fedora core 3

      Description

      It appears that XStream is not deserializing Enums correctly.

      Here is a test for proof:

      public enum MyEnum {
      Test1(), Test2();

      MyEnum() {

      }

      // public Object readResolve()

      { // return MyEnum.valueOf(this.name()); // }

      }

      MyEnum test1 = MyEnum.Test1;
      System.out.println(test1.equals(xStream.fromXML(xStream.toXML(test1))));

      If you run the previous two lines, it will print out false signifying that test1 is not equal to itself when ran through XStream. Now if you uncomment the readResolve method it works just fine, however, XStream should return the correct Enum. The problem exists in the ObjectInputStream. If you read the java docs on Enums in the ObjectInputStream, the ois should call the static method Enum.valueOf(Class, String).

        People

        • Assignee:
          Unassigned
          Reporter:
          Bryan Coleman
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: