Open
Description
jackson-dataformat-xml version: 2.9.8
When using an XMLMapper
with Jdk8Module
to serialize Stream
s, the serializer seems to ignore annotation @JacksonXmlElementWrapper
placed on a Stream
.
For example, if I try to serialize this DTO as XML:
public class StreamBasedDto {
private Stream<String> data;
@JacksonXmlElementWrapper(localName = "elements")
@JacksonXmlProperty(localName = "element")
public Stream<String> getData() {
return data;
}
public void setData(Stream<String> data) {
this.data = data;
}
}
I get the following result:
<StreamBasedDto>
<element>foo</element>
<element>bar</element>
</StreamBasedDto>
whereas I was expecting the following:
<StreamBasedDto>
<elements>
<element>foo</element>
<element>bar</element>
</elements>
</StreamBasedDto>
You can find a Java project reproducing the issue here: https://github.com/ndionisi/jackson-xml-element-wrapper-stream. The project tests that @JacksonXmlElementWrapper
is properly taken into account when serializing List
, but not when serializing Stream
.