XmlSerializerBean bug 2.14-2.16

32 views
Skip to first unread message

Thom Hehl

unread,
Nov 26, 2023, 8:24:24 PM11/26/23
to jackson-dev
I'm a newb with this project, although I've used jackson as a user for years, but never for XML before.

I have XML that looks like this:

    <div type="book" osisID="Obad">
      <chapter osisID="Obad.1">
        <verse osisID="Obad.1.1">
          <w lemma="2377" n="1.0" morph="HNcmsc" id="31xeN">חֲז֖וֹן</w>

I am deserializing into my Java class that looks like this:

public class OsisVerse extends DocumentVerse {
    @JacksonXmlElementWrapper(useWrapping = false)
    @JacksonXmlProperty(localName = "note")
    private List<OsisNote> osisNotes;
    @JacksonXmlProperty(localName = "osisID")
    private String uniqueId;
    @JacksonXmlProperty(localName = "seg")
    private String segment;
    @JacksonXmlElementWrapper(useWrapping = false)
    @JacksonXmlProperty(localName = "w")
    private List<OsisWord> osisWords;

and it de serializes great. (Thanks for a great product, BTW!)

Then I make some changes and serialize it back using the same object and here's the output I'm getting.

      <chapters>
        <chapters>
          <verse>
            <words>
              <words id="31yNB" lemma="l/4421" morph="HRd/Ncfsa" n="0" x-source-word="לַ/מִּלְחָמָֽה">(...)</words>
            </words>
            <notes/>

Note that in addition to not changing the tags back to "w", it also wrapped the list in a tag called words and then only output 1 word tag.

I have stepped through the code and watched it buffer the "w" without the list header, so I'm not sure what happened after that, but I"m pulling my hair out.

If anyone wants to have a look, you can pull https://github.com/ThomHehl/xlate and run SourceTextConverterTest.groovy. (Spock test under gradle.)

Thanks!

Thom Hehl

unread,
Nov 26, 2023, 8:31:55 PM11/26/23
to jackson-dev
I didn't see a unit test covering lists in the serialize, so I wrote one and have attached. Would appreciate someone committing it. It passes, so this stuff works, but there's something about my case that's throwing it a curve.

The bug exists in 2.14 and 2.15 as well as 2.16.
TestSerializationList.java

Tatu Saloranta

unread,
Nov 27, 2023, 11:56:08 PM11/27/23
to jacks...@googlegroups.com
On Sun, Nov 26, 2023 at 5:31 PM Thom Hehl <thom...@gmail.com> wrote:
>
> I didn't see a unit test covering lists in the serialize, so I wrote one and have attached. Would appreciate someone committing it. It passes, so this stuff works, but there's something about my case that's throwing it a curve.
>
> The bug exists in 2.14 and 2.15 as well as 2.16.

I am not sure what you mean by List handling not being covered:
`src/test/java/com/fasterxml/jackson/dataformat/xml/lists ` has more
than a dozen test classes covering various aspects.

But I can see if your test reproduces the issue for me (if I am
reading above right, it won't tho?)

-+ Tatu +-
> --
> You received this message because you are subscribed to the Google Groups "jackson-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jackson-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-dev/1c454ebc-9ffd-48e8-8cf1-b2ae991758c7n%40googlegroups.com.

Tatu Saloranta

unread,
Nov 27, 2023, 11:58:05 PM11/27/23
to jacks...@googlegroups.com
On Mon, Nov 27, 2023 at 8:55 PM Tatu Saloranta <ta...@fasterxml.com> wrote:
>
> On Sun, Nov 26, 2023 at 5:31 PM Thom Hehl <thom...@gmail.com> wrote:
> >
> > I didn't see a unit test covering lists in the serialize, so I wrote one and have attached. Would appreciate someone committing it. It passes, so this stuff works, but there's something about my case that's throwing it a curve.
> >
> > The bug exists in 2.14 and 2.15 as well as 2.16.
>
> I am not sure what you mean by List handling not being covered:
> `src/test/java/com/fasterxml/jackson/dataformat/xml/lists ` has more
> than a dozen test classes covering various aspects.
>
> But I can see if your test reproduces the issue for me (if I am
> reading above right, it won't tho?)

... and yeah, it just passes for me. Does it fail for you?

-+ Tatu +-

Thom Hehl

unread,
Nov 29, 2023, 8:40:25 AM11/29/23
to jackson-dev
Sorry, should have been more clear. The test passes, it just exercises the method right now when I found the problem. Have a look at the output file ObadShort.xml in the text directory. Make sure you get the output one and not the input one.

Joo Hyuk Kim (Vince)

unread,
Nov 29, 2023, 10:23:39 AM11/29/23
to jackson-dev
Looking at how the reproduction and expalanation are provided, we might be spending more time explaining the problem than the actual debugging.

Is it possible to file an issue with an actual reproduction written similar to issues with has-failing-test label in dataformat-xml repository?
Using plain JUnit and Jackson-only stuff.

Thom Hehl

unread,
Nov 29, 2023, 3:59:46 PM11/29/23
to jackson-dev
Reply all
Reply to author
Forward
0 new messages