XStream

XStream silently ignores unknown elements

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.2, 1.3
  • Fix Version/s: 1.3.1
  • Component/s: None
  • Labels:
    None

Description

Config.java:
public List preprocessors;
Invalid config file:
<preprocessor class="pp1"/>
<preprocessors>
<preprocessor class="pp1"/>
</preprocessors>

When reading this xml-file, XStream silently ignores the first preprocessor element.
Instead it should thrown an exception.

By looking at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter#doUnmarshal
it's found that it correctly deserializes the <preprocessor> element because the type is determined
by the class-attribute. As their is no field "preprocessor" defined in Config.java, it calls writeValueToImplicitCollection()
but this does nothing.

So the recommended work-around is throwing an Exception in writeValueToImplicitCollection() if the related
field could not be found.

Activity

Hide
Joerg Schaible added a comment -

Funny that this has not been detected ever. It only happens if the child tag actually matches a type and contains a valid object. Fixed in head. Thanks for reporting.

Show
Joerg Schaible added a comment - Funny that this has not been detected ever. It only happens if the child tag actually matches a type and contains a valid object. Fixed in head. Thanks for reporting.
Hide
Joerg Schaible added a comment -

Set correct fix version.

Show
Joerg Schaible added a comment - Set correct fix version.
Hide
Joerg Schaible added a comment -

Fixed for upcoming release.

Show
Joerg Schaible added a comment - Fixed for upcoming release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: