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

Broken deserialization on 2.13.0-rc1 for ignored non-scalar properties #3252

Closed
XakepSDK opened this issue Aug 22, 2021 · 3 comments
Closed
Milestone

Comments

@XakepSDK
Copy link
Contributor

XakepSDK commented Aug 22, 2021

Describe the bug
jackson 2.13.0-rc1 has broken deserialization
2.12.4 works fine

Version information
2.13.0-rc1

To Reproduce

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class Main {
    public static void main(String[] args) throws IOException {
        List<TestObject> testData = new ObjectMapper().readValue(
            """
                            [
                              {"name": "first entry"},
                              {"name": "second entry", "breaker": [""]},
                              {"name": "third entry"}
                            ]
                    """, new TypeReference<>() {});
        if (testData.size() != 3) throw new RuntimeException("Deserialization failed");
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class TestObject {
        @JsonProperty("name")
        private final String name;
        @JsonProperty("dumbMap")
        private final Map<String, String> dumbMap;

        @JsonCreator
        public TestObject(@JsonProperty("name") String name,
                          @JsonProperty("dumbMap") Map<String, String> dumbMap) {
            this.name = name;
            this.dumbMap = Objects.requireNonNullElse(dumbMap, Collections.emptyMap());
        }
    }
}

Expected behavior
3 items are deserialized

Additional context
Deserialization works if:
If breaker array is empty
If TestObject does not have constructor
If i deserialize into List instead of List<TestObject>, seems like it reads all entries into Map

@XakepSDK XakepSDK added the to-evaluate Issue that has been received but not yet evaluated label Aug 22, 2021
@cowtowncoder
Copy link
Member

I can reproduce the issue, thank you for reporting this.

Interesting. So somehow skipping of unrecognized breaker value triggers the problem...

@cowtowncoder cowtowncoder removed the to-evaluate Issue that has been received but not yet evaluated label Aug 22, 2021
@cowtowncoder cowtowncoder changed the title Broken deserialization on 2.13.0-rc1 Broken deserialization on 2.13.0-rc1 for ignored non-scalar properties Aug 22, 2021
@cowtowncoder
Copy link
Member

Looks like regression was introduced via #3082; not fully skipping ignored values (affects non-scalars).

@cowtowncoder cowtowncoder added this to the 2.13.0 milestone Aug 22, 2021
@cowtowncoder
Copy link
Member

Thank you @XakepSDK for reporting this regression -- it is now fixed and will go in 2.13.0!

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

2 participants