-
-
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 (or self-closing) Element representing List
is incorrectly deserialized as null, not Empty List
#252
Comments
This is still an issue 😭 val xml = """
<?xml version="1.0" encoding="utf-8"?>
<AcResponse
Command="show depots"
TaskId="1260">
<Element
Number="1"
Name="accurev"
Slice="1"
exclusiveLocking="false"
case="insensitive"
locWidth="128" />
<Element
Number="2"
Name="second accurev"
Slice="2"
exclusiveLocking="false"
case="insensitive"
locWidth="128" />
</AcResponse>
"""
val mapper : ObjectMapper = XmlMapper()
mapper.registerModule(KotlinModule())
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
val response : Depots = mapper.readValue(xml)
println(response) |
This is still an issue 😭 😭 😭 |
is this issue now resolved ? |
@saurabhkumar2015 what do you think, based on the fact issue is open and there havn't been comments? And to everyone else -- please not add arbitrary "still an issue" notes unless you add some useful information: simpler reproduction, something else you think is related. Or at very least, version in which you observe it that is more recent than earlier versions mentioned. Conversely, if you do find issue DOES NOT occur any more on some version, adding that does add information and help. |
With Version 2.9.9, the issue can be reproduced with the following quite minimal test:
|
List
is incorrectly deserialized as null, not Empty List
Isn't this already resolved: |
No. Setting |
Currently this can be done, I think, with combination of 2 things:
This would make both |
@JsonSetter works for self-closing tags('<elements/>'), but an empty wrapper tag('<elements></elements>') still produces a MismatchedInputException. |
I am hoping to tackle this for Jackson 2.12, fwtw; including both handling "blank" text and empty element the same and allowing either |
Good news! As far as I can see, tests all pass with current |
Following discussion between @allienna and @cowtowncoder on #1402 I'm creating an issue.
Hi guys,
While using Jackson with JAXB bindings, I found deserialization behaves unexpectedly on empty or self-closing elements: it sets sub-fields as null no matter what.
Here's a class to reproduce the issue (sorry if it's big):
And the Maven pom.xml (without Lombok as requested by @cowtowncoder):
If you run it, you will see that 2 tests fail:
testWrapperWithoutValues
testWrapperWithSelfClosingPojos
Now I'm anything but a JAXB or Jackson expert, so I definitely may have done mistakes or misconfigured my mapper or POJOs, in that case, any hint is appreciated.
To my surprise,
<wrapper><pojos></pojos></wrapper>
returns anull
Pojos
object, while<wrapper></wrapper>
returns an instance ofPojos
(as you can see intestWrapperWithoutPojos
test).I think this is a bug.
Dependencies to ensure we test in the same conditions:
org.projectlombok:lombok:jar:1.16.14
org.mockito:mockito-core:jar:2.7.9
com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.9.0.pr4
com.fasterxml.jackson.core:jackson-core:jar:2.9.0.pr4
com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0.pr4
com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.0.pr4
Note I also tried with jackson 2.8.9 version (for all Jackson-related libraries obviously) without this line:
and the problem remains.
The text was updated successfully, but these errors were encountered: