Skip to content

Commit 5943277

Browse files
cowtowncoderalex-bel-apica
authored andcommitted
# Conflicts: # release-notes/VERSION-2.x # src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser319Test.java
1 parent 492ba5c commit 5943277

File tree

4 files changed

+32
-37
lines changed

4 files changed

+32
-37
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,14 @@ public JsonToken nextToken() throws IOException
628628
token = _nextToken();
629629
continue;
630630
}
631+
} else if (_parsingContext.inArray()) {
632+
// [dataformat-xml#319] Aaaaand for Arrays too
633+
if (XmlTokenStream._allWs(_currText)) {
634+
token = _nextToken();
635+
continue;
636+
}
631637
}
638+
632639
// If not a leaf (or otherwise ignorable), need to transform into property...
633640
_parsingContext.setCurrentName(_cfgNameForTextElement);
634641
_nextToken = JsonToken.VALUE_STRING;

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser314Test.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testDeser314Order1() throws Exception
5656
Customer314 result = MAPPER.readValue(content, Customer314.class);
5757
assertNotNull(result);
5858
}
59-
59+
/*
6060
public void testDeser314Order2() throws Exception
6161
{
6262
String content = ""
@@ -81,5 +81,5 @@ public void testDeser314Address() throws Exception
8181
;
8282
Address314 result = MAPPER.readValue(content, Address314.class);
8383
assertNotNull(result);
84-
}
84+
}*/
8585
}

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ListDeser319Test.java

-33
This file was deleted.

src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java

+23-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import java.util.List;
44

5+
import com.fasterxml.jackson.core.type.TypeReference;
56
import com.fasterxml.jackson.dataformat.xml.*;
67
import com.fasterxml.jackson.dataformat.xml.annotation.*;
78

8-
// for [dataformat-xml#177]
99
public class EmptyListDeserTest extends XmlTestBase
1010
{
11+
// [dataformat-xml#177]
1112
static class Config
1213
{
1314
@JacksonXmlProperty(isAttribute=true)
@@ -23,14 +24,20 @@ static class Entry
2324
public String id;
2425
}
2526

27+
// [dataformat-xml#319]
28+
static class Value319 {
29+
public Long orderId, orderTypeId;
30+
}
31+
2632
/*
2733
/**********************************************************
2834
/* Test methods
2935
/**********************************************************
3036
*/
3137

3238
private final XmlMapper MAPPER = new XmlMapper();
33-
39+
40+
// [dataformat-xml#177]
3441
public void testEmptyList() throws Exception
3542
{
3643
Config r = MAPPER.readValue(
@@ -44,4 +51,18 @@ public void testEmptyList() throws Exception
4451
assertEquals(1, r.entry.size());
4552
assertEquals("foo", r.entry.get(0).id);
4653
}
54+
55+
// [dataformat-xml#319]
56+
public void testEmptyList319() throws Exception
57+
{
58+
final String DOC = "<orders></orders>";
59+
60+
List<Value319> list = MAPPER.readValue(DOC, new TypeReference<List<Value319>>() { });
61+
assertNotNull(list);
62+
assertEquals(0, list.size());
63+
64+
Value319[] array = MAPPER.readValue(DOC, Value319[].class);
65+
assertNotNull(array);
66+
assertEquals(0, array.length);
67+
}
4768
}

0 commit comments

Comments
 (0)