-
-
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
Deserializing @JacksonXmlElementWrapper(useWrapping = false) fails on missing (optional) attribute #64
Comments
Thanks, sounds like a bug. |
Would be awesome to not have to use JAXB or JiBX for this project. |
Yes. I hope to find time to fix this for 2.2.2 release. Thank you for providing the test case! |
something may or may not related test case:
exception
|
@ShijunK if you are using <dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.x</version>
</dependency> and you can remove it (i.e., use default), see if problem goes away - that solved this problem for me. I don't think that problem is related to this issue. |
@nezda , thanks, that's does not fix the problem. I was using 4.1.5, tried the latest 4.2.0. still get the same exception. |
@ShijunK did you remove the dependency as I suggested or upgrade the version? |
@nezda thanks. I misread your comment. after removing the woodstox dependency, com.sun's implementation works. |
No, please do NOT remove Woodstox dependency: Stax parser included in JDK (SJSXP) is known to have issues and even if it happened to work around one, you most likely hit something else. While I have submitted a dozen fixes for SJSXP, it is lagging far behind Woodstox in about all aspects, including both correctness and performance. |
@cowtowncoder , thanks for the advice. I did double check other test cases. and I did hit some strange exceptions after removing woodstox. For now, I will just do the dirty work to use DOM parse xml for my use case. one strange exception after removing woodstox dependency:
|
You can also try JAXB -- it is fairly solid, and much faster than playing with DOM. |
FWIW, while I am happy to accept patches to make module work better with default Stax parser from JDK, I will not be investigating problems specific to it (i.e. things that work with Woodstox). Others are free to pursue these aspects of course. |
Another note: each bug entry should be for specific problem; new ones should be filed for other problems, unless they are known to be directly related. I mention this since unit test included seems to point out different issues. |
I believe this is finally properly fixed. The problem turned out to be related to "auto-detection" of leaf-level String values: in case where this may occur, need to add explicit support for serializing POJO from a String value. |
Attempting to deserialize an unwrapped collection field (
@JacksonXmlElementWrapper(useWrapping = false)
) fails if element is missing an attribute. For example, given:XmlMapper
can handle<MultiOptional><optional type='work'>123-456-7890</optional></MultiOptional>
but not
<MultiOptional><optional>123-456-7890</optional></MultiOptional>
(since it is missingtype
property).Here are some related additions I made to
com.fasterxml.jackson.dataformat.xml.failing.TestDeserialization
to refine this issue:The text was updated successfully, but these errors were encountered: