Skip to content

Commit 5d92058

Browse files
committed
Fix FasterXML#509: Do not throw when parsing mixed content arrays
1 parent 66af793 commit 5d92058

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,11 @@ public JsonToken nextToken() throws IOException
845845
token = _nextToken();
846846
continue;
847847
}
848-
// 29-Mar-2021, tatu: This seems like an error condition...
849-
// How should we indicate it? As of 2.13, report as unexpected state
850-
throw _constructError(
851-
"Unexpected non-whitespace text ('"+_currText+"' in Array context: should not occur (or should be handled)"
852-
);
848+
// [dataformat-xml#509] 2.13 introduced a defect in which an Exception was thrown here, breaking
849+
// parsing of mixed content arrays (https://github.com/FasterXML/jackson-dataformat-xml/issues/509).
850+
// This exception case was removed to enable continued support of that functionality, but more
851+
// robust state handling may be in order.
852+
// See comment https://github.com/FasterXML/jackson-dataformat-xml/pull/604#issuecomment-1770080319
853853
}
854854

855855
// If not a leaf (or otherwise ignorable), need to transform into property...
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package com.fasterxml.jackson.dataformat.xml.failing;
1+
package com.fasterxml.jackson.dataformat.xml.deser;
22

33
import java.util.*;
44

55
import org.junit.Test;
66

77
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
8-
98
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
9+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
1010
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
1111
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
1212

@@ -31,6 +31,8 @@ public void setKey(java.lang.String value) {
3131
}
3232

3333
static class MetaData {
34+
@JacksonXmlElementWrapper(useWrapping = false)
35+
@JacksonXmlProperty(localName = "data")
3436
protected List<Data> data;
3537

3638
public List<Data> getData() {

0 commit comments

Comments
 (0)