jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • XStream
  • XSTR-245

Broken XML output serializing class with custom writeObject()

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.2
  • Component/s: None
  • Labels:
    None
  • JDK version and platform:
    Sun 1.4.2_09 for Windows

Description

XStream generates bad XML of Class1 has a transient field class2 of type Class2 and has a custom writeObject() method that writes class2 before calling defaultWriteObject(). Class2 has a custom writeObject() method that simply calls defaultWriteObject(). The default section for Class1duplicates the default section for Class2 rather than the declared fields of Class1.

I wasn't sure how to generate a JUnit test for this, but I've attached a simple, stand-alone Java file with a simple test case that writes the XML to System.out.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Class1.java
    27/Sep/05 11:21 AM
    1 kB
    Philip Gust
  2. XML File
    Class1.xml
    27/Sep/05 11:25 AM
    0.4 kB
    Philip Gust
  3. Java Source File
    SerializableConverterTest.java
    08/Jun/06 2:00 PM
    4 kB
    Cyrille Le Clerc
  4. Text File
    XSTR-245.patch
    08/Jun/06 9:52 PM
    22 kB
    Cyrille Le Clerc
  5. Text File
    XSTR-245-0.1-draft.patch
    08/Jun/06 2:00 PM
    20 kB
    Cyrille Le Clerc

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
Hide
Permalink
Philip Gust added a comment - 27/Sep/05 11:25 AM

This file contains the output from running the attached Class1.java. The XML for Class1's default section is wrong: it duplicates the default section for Class2.

Show
Philip Gust added a comment - 27/Sep/05 11:25 AM This file contains the output from running the attached Class1.java. The XML for Class1's default section is wrong: it duplicates the default section for Class2.
Hide
Permalink
Cyrille Le Clerc added a comment - 08/Jun/06 2:00 PM

Here is a proposed TestCase and a proposed draft version of a patch. If fixes the XSTR-245 but additional test cases should be added.

The main idea of the patch is to use a stack of callBacks in CustomObjectInputStream and CustomObjectOutputStream instead of the previous version that only hold the current callback.

Show
Cyrille Le Clerc added a comment - 08/Jun/06 2:00 PM Here is a proposed TestCase and a proposed draft version of a patch. If fixes the XSTR-245 but additional test cases should be added. The main idea of the patch is to use a stack of callBacks in CustomObjectInputStream and CustomObjectOutputStream instead of the previous version that only hold the current callback.
Hide
Permalink
Cyrille Le Clerc added a comment - 08/Jun/06 9:52 PM

Final version of a proposed patch.

Main idea :
Use a stack of StreamCallbacks in CustomObjectInputStream and CustomObjectOutputStream instead of the previous version that only hold the current streamCallback.

Comments:
Even if this bug was related to SerializableConverter, I modified ExternalizableConverter to apply the same pattern.

Modified files :

  • CustomObjectInputStream and CustomObjectOutputStream to add these stacks
  • SerializableConverter doMarshal and doUnmarshal to call popCallback()
    Note that pushCallback is not called by SerializableConverter but by CustomObjectOutputStream#getInstance
  • ExternalizableConverter same modifications as for SerializableConverter

Created files :

  • SerializationNestedWriteObjectsTest testcase in the acceptance package

Tests and build:
Patch was developped against subversion trunk #866. All the tests passed successfully and ant build succeeded

Show
Cyrille Le Clerc added a comment - 08/Jun/06 9:52 PM Final version of a proposed patch. Main idea : Use a stack of StreamCallbacks in CustomObjectInputStream and CustomObjectOutputStream instead of the previous version that only hold the current streamCallback. Comments: Even if this bug was related to SerializableConverter, I modified ExternalizableConverter to apply the same pattern. Modified files :
  • CustomObjectInputStream and CustomObjectOutputStream to add these stacks
  • SerializableConverter doMarshal and doUnmarshal to call popCallback() Note that pushCallback is not called by SerializableConverter but by CustomObjectOutputStream#getInstance
  • ExternalizableConverter same modifications as for SerializableConverter
Created files :
  • SerializationNestedWriteObjectsTest testcase in the acceptance package
Tests and build: Patch was developped against subversion trunk #866. All the tests passed successfully and ant build succeeded
Hide
Permalink
Joerg Schaible added a comment - 12/Jun/06 3:08 AM

I've applied a slightly modified patch of Cyrille. Cyrille & Philip, does this work for you?

Show
Joerg Schaible added a comment - 12/Jun/06 3:08 AM I've applied a slightly modified patch of Cyrille. Cyrille & Philip, does this work for you?
Hide
Permalink
Cyrille Le Clerc added a comment - 13/Jun/06 8:24 PM

It work successfully for me (svn revision 870).

Show
Cyrille Le Clerc added a comment - 13/Jun/06 8:24 PM It work successfully for me (svn revision 870).

People

  • Assignee:
    Unassigned
    Reporter:
    Philip Gust
Vote (0)
Watch (2)

Dates

  • Created:
    27/Sep/05 11:21 AM
    Updated:
    07/Aug/06 9:19 PM
    Resolved:
    12/Jun/06 3:08 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.