Skip to content

Commit

Permalink
Fix #86
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 13, 2020
1 parent e6e5a5f commit 5af8b0c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ Alexei Volkov (softkot@github)
* Reported #294: XML parser error with nested same element names
(2.11.1)

Eric Schoonover (spoon16@github)

* Reported #86: Can not deserialize unwrapped list when `@JacksonXmlProperty` localName
matches `@JacksonXmlRootElement` localName
(2.12.0)

Joseph Petersen (jetersen@github)

* Reported #273: Input mismatch with case-insensitive properties
Expand Down
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Project: jackson-dataformat-xml

2.12.0 (not yet released)

#86: Can not deserialize unwrapped list when `@JacksonXmlProperty` localName
matches `@JacksonXmlRootElement` localName
(reported by Eric S)
#273: Input mismatch with case-insensitive properties
(reported by Joseph P)
#318: XMLMapper fails to deserialize null (POJO reference) from blank tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,23 @@ public XMLStreamReader getStaxReader() {
*/
public void addVirtualWrapping(Set<String> namesToWrap0, boolean caseInsensitive)
{
//System.out.printf("addVirtualWrapping(%s) [case-insensitive? %s]\n", namesToWrap0, caseInsensitive);
//System.out.printf("addVirtualWrapping(%s) at '%s' [case-insensitive? %s]\n", namesToWrap0, _parsingContext.pathAsPointer(), caseInsensitive);

final Set<String> namesToWrap = caseInsensitive
? CaseInsensitiveNameSet.construct(namesToWrap0)
: namesToWrap0;

// 17-Sep-2012, tatu: Not 100% sure why, but this is necessary to avoid
// 17-Sep-2012, tatu: Not 100% sure why, but this is necessary to avoid
// problems with Lists-in-Lists properties
String name = _xmlTokens.getLocalName();
if ((name != null) && namesToWrap.contains(name)) {
// 12-May-2020, tatu: But as per [dataformat-xml#86] NOT for root element
// (would still like to know why work-around needed ever, but...)
if (_parsingContext.inObject()
&& !_parsingContext.getParent().inRoot()) {
String name = _xmlTokens.getLocalName();
if ((name != null) && namesToWrap.contains(name)) {
//System.out.println("REPEAT from addVirtualWrapping()");
_xmlTokens.repeatStartElement();
_xmlTokens.repeatStartElement();
}
}
_parsingContext.setNamesToWrap(namesToWrap);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.dataformat.xml.failing;
package com.fasterxml.jackson.dataformat.xml.lists;

import java.util.Arrays;
import java.util.List;
Expand All @@ -11,7 +11,7 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;

public class TestUnwrappedDeserIssue86 extends XmlTestBase
public class NestedUnwrappedLists86Test extends XmlTestBase
{
@JacksonXmlRootElement(localName = "test")
public static class Issue86 {
Expand Down

3 comments on commit 5af8b0c

@sandboxcoder
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really could use this fix. Just encountered this bug at work. I don't suppose you could make a release candidate? Thanks

@cowtowncoder
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandboxgod No, unfortunately it's rather too early for that as 2.11.0 is just out, and making a full set of rcs is about as much work as full minor release.

There are snapshot builds available via Sonatype OSS repo, if that would help.

However... looking at the fix itself, this just might be possible to backport in 2.11, for 2.11.1 which is likely to be released well before 2.12 release candidates. This because fix seems safe (I try to be quite conservative wrt changes in patch releases), after completing it.

Would that be interesting to you?

@sandboxcoder
Copy link

@sandboxcoder sandboxcoder commented on 5af8b0c May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested, I tried using the latest snapshot (I saw version 2.12.0) but the issue still happens. I uploaded a sample project:
fullStackAngularSpringBoot.zip

I think in order to repro you need to have an xml setup like this:

<main>
    <test>
        <test>
            <test>

            </test>
        </test>
    </test>
    <test>

    </test>
</main>

As you can see, the test object can refer to children test objects.

I'm hoping you can address if possible. Thanks

  • Btw I did like the idea about backporting the upcoming fix into 2.11.

I opened a new issue here: #399

Please sign in to comment.