FasterXML / FasterXML/jackson-dataformat-xml
Collection values overwritten if item elements are not contiguous (mixed content)
- 主要語言
- Java
- 星號
- 631
- 分支
- 246
- 平均合併
- 7 天 9 小時
- 30 天內合併 PR
- 13
描述
Looks like we have a bug in the parser. Parsing next simple document leads to data loss.
```
foo1
foo2
bar1
foo3
foo4
```
Expected result: `foo` java-property contains list of 4 values.
Actual result: `foo` java-property contains list of 2.
Setter for `foo` property is called two times for every tags group: `foo1, foo2` and `foo3, foo4`. Second setter call overrides data gathered by the first call. As result parsing result contains `foo` list as `foo3, foo4` instead of expected `foo1, foo2, foo3, foo4`.
Here is a java-code to reproduce the issue.
```
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.util.List;
@JacksonXmlRootElement(localName = "data")
class Data {
@JacksonXmlCData
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty
private List foo;
@JacksonXmlCData
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty
private List bar;
public List getFoo() {
return foo;
}
public void setFoo(List foo) {
this.foo = foo;
}
public List getBar() {
return bar;
}
public void setBar(List bar) {
this.bar = bar;
}
}
public class Foo {
public static void main(String[] args) throws JsonProcessingException {
String xml = ""
+ ""
+ " foo1"
+ " foo2"
+ " bar1"
+ " foo3"
+ " foo4"
+ "";
XmlMapper m = new XmlMapper();
Data data = m.readValue(xml, Data.class);
System.err.println(data.getFoo()); // Expected ["foo1", "foo2", "foo3", "foo4"] but ["foo3", "foo4"] given.
}
}
```
jackson-dataformat-xml version: 2.10.0
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。