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

Create reproducer test case for #509 #604

Merged
merged 4 commits into from
Oct 19, 2023
Merged

Conversation

ptziegler
Copy link
Contributor

@ptziegler ptziegler commented Jul 28, 2023

This adds two additional test cases to reproduce #509. Those tests attempt to deserialize the two classes Data and MetaData.

The MetaData class simply contains a list of Data objects. The Data class contains a "key", which is derived from the attribute of the XML node, and a "content" list, which is the arbitrary data stored inside that node.

@ptziegler
Copy link
Contributor Author

Test Result:

[ERROR] Failures: 
[ERROR]   UnexpectedNonWhitespaceText509Test.testDeSerData:81->deSer:106 Unrecognized field "" (class com.fasterxml.jackson.dataformat.xml.deser.UnexpectedNonWhitespaceText509Test$Data), not marked as ignorable (2 known properties: "content", "key"])
 at [Source: (StringReader); line: 1, column: 40] (through reference chain: com.fasterxml.jackson.dataformat.xml.deser.UnexpectedNonWhitespaceText509Test$Data[""])
[ERROR]   UnexpectedNonWhitespaceText509Test.testDeSerMetaData:88->deSer:106 Unexpected non-whitespace text ('Text Editor' in Array context: should not occur (or should be handled)
 at [Source: (StringReader); line: 2, column: 44] (through reference chain: com.fasterxml.jackson.dataformat.xml.deser.UnexpectedNonWhitespaceText509Test$MetaData["data"])

This adds two additional test cases. Those tests attempt to deserialize
the two classes Data and MetaData.

The MetaData class simply contains a list of Data objects. The Data
class contains a "key", which is derived from the attribute of the XML
node, and a "content" list, which is the arbitrary data stored inside
that node.
@ptziegler
Copy link
Contributor Author

Here's also the updated test run + stack trace.

com.fasterxml.jackson.dataformat.xml.deser.UnexpectedNonWhitespaceText509Test.txt

@cowtowncoder
Copy link
Member

Ok: one quick note -- this is bit problematic as it has JAXB/Jakarta-RS annotations, which are only supported when appropriate module is registered, which is not done here. But it also ideally should be avoided as XML module does not have direct dependency to JAXB/Jakarta-RS annotations module; we do have test dep to JAXB one but not the other yet.

It'd be good to instead use Jackson annotations as there are equivalents for all annotations that are supported.

I hope to have time to look into this.

@cowtowncoder
Copy link
Member

Ok seems to use Java 9 methods too, will need to modify a bit.

@cowtowncoder
Copy link
Member

Ok this is not supportable at all: Jackson does not support concept of "any" XML content that content property here is trying to do.

With 2.16.0-SNAPSHOT I do get exception for mismatched property, which relates to textual content within <data>: this can be mapped using @XmlText (or whatever it was in JAXB), or, @JacksonXmlText. But it has to be String or similar type; there is no mechanism for collecting multiple segments. Nor is there any plans to try to do that.
It is part of JAXB/Jakarta-binding that Jackson does not and will not support (support is only for subset of annotations, not for model itself).

What can be done is that whole <data> can be mapped to either Map<String, Object> (of java.lang.Object which becomes Map) or JsonNode. These are only construct that support true mixed content.

I will close this PR and will see whether #509 itself is worth investigating.

@cowtowncoder
Copy link
Member

Hmmh. Actually I take this back. After using @JacksonXmlText I can see the exception that seems wrong.
Maybe this is usable after all.

@cowtowncoder
Copy link
Member

Ok, I think the problem is not the assertion with exception, but state handling; text segment should be handled same as within regular Object; it is not directly within Array context.
So I think that with changes this reproduction is useful; may merge as failing test and hopefully have time to figure it out.

@cowtowncoder cowtowncoder merged commit bc0adc2 into FasterXML:2.16 Oct 19, 2023
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants