-
- Notifications
You must be signed in to change notification settings - Fork 233
Open
Labels
recordIssue related to Java 17+ Record type handlingIssue related to Java 17+ Record type handling
Description
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.
FoKas90, afranken, Adrodoc, guimeira, TWiStErRob and 2 more
Metadata
Metadata
Assignees
Labels
recordIssue related to Java 17+ Record type handlingIssue related to Java 17+ Record type handling