Skip to content

Commit

Permalink
Fixed #319
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 5, 2020
1 parent c25683e commit a379cab
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Expand Up @@ -17,6 +17,8 @@ Project: jackson-dataformat-xml
(reported by Joseph P)
#318: XMLMapper fails to deserialize null (POJO reference) from blank tag
(reported by Jochen S)
#319: Empty root tag into `List` deserialization bug
(reported by Seatec13@github)
#377: `ToXmlGenerator` ignores `Base64Variant` while serializing `byte[]`
(reported by Ghenadii B)
#397: `XmlReadContext` does not keep track of array index
Expand Down
Expand Up @@ -666,7 +666,14 @@ public JsonToken nextToken() throws IOException
token = _nextToken();
continue;
}
} else if (_parsingContext.inArray()) {
// [dataformat-xml#319] Aaaaand for Arrays too
if (XmlTokenStream._allWs(_currText)) {
token = _nextToken();
continue;
}
}

// If not a leaf (or otherwise ignorable), need to transform into property...
_parsingContext.setCurrentName(_cfgNameForTextElement);
_nextToken = JsonToken.VALUE_STRING;
Expand Down
Expand Up @@ -54,7 +54,7 @@ public void testDeser314Order1() throws Exception
Customer314 result = MAPPER.readValue(content, Customer314.class);
assertNotNull(result);
}

/*
public void testDeser314Order2() throws Exception
{
String content = ""
Expand All @@ -79,5 +79,5 @@ public void testDeser314Address() throws Exception
;
Address314 result = MAPPER.readValue(content, Address314.class);
assertNotNull(result);
}
}*/
}

This file was deleted.

Expand Up @@ -2,12 +2,13 @@

import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.*;

// for [dataformat-xml#177]
public class EmptyListDeserTest extends XmlTestBase
{
// [dataformat-xml#177]
static class Config
{
@JacksonXmlProperty(isAttribute=true)
Expand All @@ -23,14 +24,20 @@ static class Entry
public String id;
}

// [dataformat-xml#319]
static class Value319 {
public Long orderId, orderTypeId;
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final XmlMapper MAPPER = new XmlMapper();


// [dataformat-xml#177]
public void testEmptyList() throws Exception
{
Config r = MAPPER.readValue(
Expand All @@ -44,4 +51,18 @@ public void testEmptyList() throws Exception
assertEquals(1, r.entry.size());
assertEquals("foo", r.entry.get(0).id);
}

// [dataformat-xml#319]
public void testEmptyList319() throws Exception
{
final String DOC = "<orders></orders>";

List<Value319> list = MAPPER.readValue(DOC, new TypeReference<List<Value319>>() { });
assertNotNull(list);
assertEquals(0, list.size());

Value319[] array = MAPPER.readValue(DOC, Value319[].class);
assertNotNull(array);
assertEquals(0, array.length);
}
}

0 comments on commit a379cab

Please sign in to comment.