Skip to content

Failure to deserialize unwrapped list where entry has empty content, attribute(s) #177

@cowtowncoder

Description

@cowtowncoder

Basically, for content defined like:

    static class Config
    {
        @JacksonXmlProperty(isAttribute=true)
        public String id;

        @JacksonXmlElementWrapper(useWrapping=false)
        public List<Entry> entry;
    }

    static class Entry
    {
        @JacksonXmlProperty(isAttribute=true)
        public String id;
    }

content like:

<Config id='123'>
  <entry id='foo'> </entry>
</Config>

will result in exception like:

    com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "" (class com.fasterxml.jackson.dataformat.xml.failing.EmptyListTest$Entry), not marked as ignorable (one known property: "id"])
 at [Source: java.io.StringReader@5a7baa77; line: 2, column: 28] (through reference chain: com.fasterxml.jackson.dataformat.xml.failing.Config["entry"]->java.util.ArrayList[0]->com.fasterxml.jackson.dataformat.xml.failing.Entry[""])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:62)

Note that problem does NOT occur if any of following is true:

  • element (<entry>) does NOT have attribute(s)
  • element has a child element
  • element has no textual content (so, either <entry /> or <entry></entry>)

but only with one or more attributes, and all-whitespace "content".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions