Using @JacksonXmlElementWrapper and @JacksonXmlProperty annotations with Java records results in deserialization exception.
For example, I'd expect following XML:
<Request>
<messages>
<message>
<text>given text</text>
</message>
</messages>
</Request>
to deserialize into following java records:
public record Request(
@JacksonXmlElementWrapper(localName = "messages")
@JacksonXmlProperty(localName = "message")
List<Message> messages
) {
public Request {
}
private Request() {
this(null);
}
}
public record Message(String text) {
public Message {
}
private Message() {
this(null);
}
}
However, it results in an exception:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid definition for property 'messages' (of type `Request`): Could not find creator property with name 'messages' (known Creator properties: [message])
at [Source: (StringReader); line: 1, column: 10]
This is unexpected because deserialization works with equivalent java classes.
This happens with Java 17 and Jackson version 2.13.2, which is the latest one as of this writing.
I've put together a minimal project which showcases the issue: jackson-record-showcase.
Using
@JacksonXmlElementWrapperand@JacksonXmlPropertyannotations with Java records results in deserialization exception.For example, I'd expect following XML:
to deserialize into following java records:
However, it results in an exception:
This is unexpected because deserialization works with equivalent java classes.
This happens with Java 17 and Jackson version 2.13.2, which is the latest one as of this writing.
I've put together a minimal project which showcases the issue: jackson-record-showcase.