-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Empty tags cause incorrect deserialization of unwrapped lists #469
Comments
@cowtowncoder do you believe it is a Jackson issue or have we misconfigured something? |
Sounds like a potential bug but I haven't really had time to dig into this. Two suggestions:
Other than configuration of wrapping/no-wrapping for |
Thanks for the hints! The serialization produces exactly the same XML as we are providing as the input in the test case, which suggests that the XML structure is correct. One more thing, if we set the: |
@jackson-code1 I don't think you did try using Jackson for serializing actual structure since the way I see, structure does differ: wrapping is used for So the problem IS that wrapping is used for
or configure And what is happening with input is simple: you get |
@cowtowncoder I tried with the annotation you suggested but the test case is still red. With regard to serialization, yes we tried serializing the following input:
which results in:
You mentioned that the attribute of Inner2 might be ignored but we tried it also with a non-empty Inner2 and the behavior was the same. |
Ok that is strange; I wonder if the issue is related to JAXB annotations. In my case I have a simplified version, using Jackson annotations. I think I'll check in version in git and add a link, easier than embedding. |
Oh, one thing: if you are using
Alternatively if you want to default to "no wrapper" style, you can avoid annotations and just use:
This is probably simpler thing to do. |
Thank you for investigating it and for the unit test! It looks like the annotations are the issue - I slightly modified the test case and witch the JAXB annotations (XmlAttribute, XmlElement) the test case fails:
|
@cowtowncoder so we managed to break your test case by using:
The false flag is meant to set useWrapper = false The test case is green only if the following 2 conditions are met:
which assumes a selective use pf the useWrapping flag. The problem with this approach is that we are not sure which properties in our model should use wrapping and which not. Would you be able to investigate the wrapping issue further or give us some hints how we could mitigate it? |
Hmmh. This is weird. It seems as if serialization behavior changes as expected, but deserialization still fails. Your usage is correct and there should be no need to use both annotation and annotation introspector settings. |
Finally figured out actual triggering condition: it does not seem to be the annotation introspector, but rather depends entirely on whether EDIT: also looks like simplified version of this causes fail: <outer>
<inner1/>
<inner2 str2='aaaa'/>
</outer> but making attribute element passes: <outer>
<inner1/>
<inner2>
<str2>aaaa</str2>
</inner2>
</outer> so there is something odd in handling of unwrapped Lists, wrt attributes. |
Thank you very much, @cowtowncoder, for tackling it! Is there any way how we could use the fix locally before the official release? |
@jackson-code1 Typically you can either build and install ( I don't know if you could work around it by sub-classing or so -- but your reference to |
I have a hunch that the fix for this broke our XML parsing when upgrading our Kotlin project from 2.12.3 to 2.12.4. We parse a test.csproj file that looks like
into Kotlin data classes that look like
with the line
This used to work in 2.12.3 and resulted in
but with 2.12.4 we get
with the same code. |
We spotted an issue when trying to deserialize an empty tag followed by a list property.
Beans:
Test case:
Actual output:
Expected output:
The problem seems to be related to deserialization, because deserializedBean has the Inner1 field value (populated with null values) but the Inner2 field does not deserialize correctly. (the deserialized Inner2 field is an empty list)
It is worth mentioning, that, if you remove the from the xmlInput or if Inner1 is a non-empty tag with a valid value then the Inner2 field gets deserialized correctly.
Library versions:
jackson-annotations-2.12.3.jar,
jackson-core-2.12.3.jar,
jackson-databind-2.12.3.jar,
jackson-dataformat-xml-2.12.3.jar,
jackson-module-jaxb-annotations-2.12.3.jar,
The text was updated successfully, but these errors were encountered: