Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty root tag deserialization bug #2163

Open
Seatec13 opened this issue Oct 24, 2018 · 0 comments
Open

Empty root tag deserialization bug #2163

Seatec13 opened this issue Oct 24, 2018 · 0 comments

Comments

@Seatec13
Copy link

Hello,
I have a strange problem with jackson-databind 2.9.* (with 2.8.* everything work good):

Data class:

@Data
public class PackInstanceOrder {
    private Long orderId;
    private Long orderTypeId;
}

Simple test:


    @Test
    fun test() {
        val XML_OBJECT_MAPPER = XmlMapper()

        val xml = "<orders></orders>"
        val orders: List<PackInstanceOrder> = XML_OBJECT_MAPPER.readValue(xml,
            XML_OBJECT_MAPPER.getTypeFactory().constructCollectionType(List::class.java, PackInstanceOrder::class.java))

        assertThat(orders, notNullValue())
    }

throw an error:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "" (class PackInstanceOrder), not marked as ignorable (2 known properties: "orderId", "orderTypeId"])
at [Source: (StringReader); line: 1, column: 18] (through reference chain: java.util.ArrayList[0]->PackInstanceOrder[""])

When adding @JsonIgnoreProperties(ignoreUnknown = true) annotation to PackInstanceOrder, error was changed:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected end-of-input when binding data into PackInstanceOrder
at [Source: (StringReader); line: 1, column: 18] (through reference chain: java.util.ArrayList[1])

BUT! When I change xml to
<orders/>
test didn't throw any errors and pass well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant