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

XmlMapper/UntypedObjectDeserializer mixes multiple unwrapped collections #445

Closed
drewko opened this issue Jan 13, 2021 · 3 comments
Closed
Milestone

Comments

@drewko
Copy link

drewko commented Jan 13, 2021

Hi I found an issue with deserializing xml node containg multiple unwrapped collections.

Entity

<person>
    <name>a</name>
    <name>b</name>
    <surname>c</surname>
    <surname>d</surname>
</person>

Code

new XmlMapper().readValue(xml, Object.class);

Output

{
    name = [ c, d ], 
    surname = d
}

Problem
Could not deserialize node that contains multiple unwrapped collections. If I remove one surname, so that name is the only collection - it works properly.

Version: 2.12.1

@cowtowncoder
Copy link
Member

Thank you for reporting this: sounds like a problem indeed. I hope to have a look soon, will add to my todo list.

@Migwel
Copy link
Contributor

Migwel commented Jan 24, 2021

@cowtowncoder I'm happy to give it a try. To be sure, the expected behavior is that the XML is serialized into

{
    name = [ a, b ], 
    surname = [c, d]
}

?

After a quick look, the issue seems to be coming from the way we handle duplicates in com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.Vanilla#_mapObjectWithDups where the code gets confused. It could be related to #205

@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 25, 2021

@Migwel yes definitely that would be expected. One easy thing to start with would be to write a simple test case, along with ones that exist, under "src/test/java/.../failing" in jackson-dataformat-xml -- this even if the issue itself is on databind side, I think (easier to test although technically testing would be doable with some work on databind).
Fix should be for 2.12, I think, so branch to use would be 2.12.

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

3 participants