Skip to content

Java Record with @JacksonXmlText stop working with 2.18 #735

@akastyka

Description

@akastyka

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

Following class can't be deserialized with Jackson 2.18.2:
public record Variable( @JacksonXmlProperty(isAttribute = true, localName = "name") String name, @JacksonXmlText String value) {}

deserialization fails with:
Invalid definition for property '' (of type com.Variable): Could not find creator property with name '' (known Creator properties: [name, value]) at [Source: (StringReader); line: 1, column: 1]

it works with Jackson 2.17.2. Also it works with 2.18.2 but with POJO only

Version Information

2.18.2

Reproduction

-->

public record Variable(
        @JacksonXmlProperty(isAttribute = true, localName = "name") String name,
        @JacksonXmlText String value) {
    public static void deserialize() throws JsonProcessingException {
        XmlMapper xmlMapper = new XmlMapper();

        Variable deserialized = xmlMapper.readValue(
                "<jackson name=\"value\">test</jackson>", Variable.class);
        System.out.println(deserialized);
    }
}

Expected behavior

Java record is deserialized

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions