Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cowtowncoder opened this issue Dec 23, 2015 · 0 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant