History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-280
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Joerg Schaible
Reporter: Joe Walnes
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XStream

omitField() and aliasField() does not get taken into account by SerializableConverter

Created: 02/Mar/06 11:09 AM   Updated: 25/Feb/08 05:01 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3

File Attachments: 1. Java Source File doMarshal_patch.java (7 kb)
2. Text File patch-omitted-inherited-fields-test.txt (4 kb)
3. Text File patch-omitted-inherited-fields.txt (8 kb)

Issue Links:
Supercedes
 


 Description  « Hide
The XStream.omitField() method behaves as expected for ReflectionConverter. However, when an object uses custom serialization (writeObject()) and calls ObjectOutputStream.defaultWriteOut(), the fields are not omitted. This is because SerializableConverter does not take into account these fields.

Example of this can be seen here: http://article.gmane.org/gmane.comp.java.xstream.user/1478

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 03/Mar/06 01:40 AM
It also does not honor the new alias mechanism for fields. Now that we have an AbstractReflectionConverter, we can maybe refactore the code even more to support both issues with one code base.

Joerg Schaible - 16/Mar/06 07:37 PM
Neither does the JavaBeanConverter ...

brien colwell - 29/Aug/06 02:00 PM
This is a quick patch for SerializableConverter

Derrick Kittler - 15/Nov/06 06:57 PM
I ran into this issue today while trying to be explicit about the XML serialization of one of my domain objects. I, much like this issue states, cannot omit fields from the XStream object, for example:
        XStream xs = new XStream();
        if(entity instanceof Metadata )
        {
            xs.omitField(Project.class, "project"); // TODO http://jira.codehaus.org/browse/XSTR-280 //$NON-NLS-1$
            xs.omitField(MetadataValue.class, "metadataValues"); // TODO http://jira.codehaus.org/browse/XSTR-280 //$NON-NLS-1$
        }
        String xml = xs.toXML(entity);
       
The resulting string will contain the elements <project>...</project> and <metadataValues>...</metadataValues> What I would like is the resulting XML string to *not* serialize these attributes into XML; rather omit them from the final XML string.


Derrick Kittler - 07/Feb/07 08:50 AM
I compiled the Patch in and it still does not have the proper result .... there is no omission of XML elements when using:
xStream.omitField(MyClass.class, "myClassProperty");


Hinse ter Schuur - 23/Jul/07 04:57 AM
This is a quick patch for JavaBeanConverter

Hinse ter Schuur - 23/Jul/07 04:57 AM
A simple test to check if javabean respects the omitted fields

Hinse ter Schuur - 24/Jul/07 07:37 AM
Modified patch with fixes for inheritance of omitted fields and field aliases

Joerg Schaible - 26/Jul/07 05:08 PM
The patch for the JavaBeanConverter has been applied.

Joerg Schaible - 19/Aug/07 03:16 PM
Alias and omit field is now also respected by the SerializableConverter.

Joerg Schaible - 25/Feb/08 05:01 PM
Closing issues before next release.