Skip to content

Commit c3b48f3

Browse files
authored
Fix #509 (re-created #651 with changes) (#652)
1 parent 66af793 commit c3b48f3

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

release-notes/CREDITS-2.x

+8
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,11 @@ Motonori IWAMURO (vmi@github)
243243
* Contributed fix for #616: Fix mismatch in `setNextIsUnwrapped(boolean)` in
244244
`XmlBeanSerializerBase#serializeFieldsFiltered()`
245245
(2.16.1)
246+
247+
Dennis Cornwell (@cornwe19)
248+
249+
* Reported #509: Exception when parsing `List`s of mixed content (since 2.13.0)
250+
251+
Christopher R. Wicks (@wickstopher)
252+
253+
* Contributed fix for #509: Exception when parsing `List`s of mixed content (since 2.13.0)

release-notes/VERSION-2.x

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Project: jackson-dataformat-xml
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
2.16.3 (not yet released)
8+
9+
#509: Exception when parsing `List`s of mixed content (since 2.13.0)
10+
(reported by Dennis C)
11+
(fix contributed by Christopher R. W)
12+
713
2.16.2 (09-Mar-2024)
814

915
No changes since 2.16.1

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,17 @@ public JsonToken nextToken() throws IOException
847847
}
848848
// 29-Mar-2021, tatu: This seems like an error condition...
849849
// How should we indicate it? As of 2.13, report as unexpected state
850+
/*
850851
throw _constructError(
851-
"Unexpected non-whitespace text ('"+_currText+"' in Array context: should not occur (or should be handled)"
852+
"Unexpected non-whitespace text ('"+_currText+"') in Array context: should not occur (or should be handled)"
852853
);
854+
*/
855+
856+
// [dataformat-xml#509] 2.13 introduced a defect in which an Exception was thrown above, breaking
857+
// parsing of mixed content arrays (https://github.com/FasterXML/jackson-dataformat-xml/issues/509).
858+
// This exception case was removed to enable continued support of that functionality, but more
859+
// robust state handling may be in order.
860+
// See comment https://github.com/FasterXML/jackson-dataformat-xml/pull/604
853861
}
854862

855863
// If not a leaf (or otherwise ignorable), need to transform into property...

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UnexpectedNonWhitespaceText509Test.java src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UnexpectedNonWhitespaceText509Test.java

+4-2
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)