Skip to content

Afterburner with joda module does not always include null values #14

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

Closed
esiqveland opened this issue Jun 23, 2016 · 1 comment
Closed

Comments

@esiqveland
Copy link

Afterburner together with joda module does not always include null values.

Test to reproduce:

    @JsonInclude(JsonInclude.Include.ALWAYS)
    static class TestClass {
        @JsonProperty("name")
        private String name;
        @JsonProperty("id")
        private String id;
        @JsonProperty("created_at")
        private DateTime created_at;
        @JsonProperty("updated_at")
        private DateTime updated_at;

        public String getName() {
            return name;
        }

        public TestClass setName(String name) {
            this.name = name;
            return this;
        }

        public String getId() {
            return id;
        }

        public TestClass setId(String id) {
            this.id = id;
            return this;
        }

        public DateTime getCreated_at() {
            return created_at;
        }

        public DateTime getUpdated_at() {
            return updated_at;
        }

        public TestClass setCreated_at(final DateTime created_at) {
            this.created_at = created_at;
            return this;
        }

        public TestClass setUpdated_at(final DateTime updated_at) {
            this.updated_at = updated_at;
            return this;
        }

    }

    @Test
    public void test_serialize_jackson() throws JsonProcessingException {

        TestClass tilstand = new TestClass()
                .setId(null)
                .setName("name")
                .setUpdated_at(null)
                .setCreated_at(new DateTime());

        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JodaModule());
        mapper.registerModule(new AfterburnerModule());

        String json = mapper.writeValueAsString(tilstand);

        assertThat(json, containsString("id"));
        assertThat(json, containsString("name"));
        assertThat(json, containsString("updated_at"));
        assertThat(json, containsString("created_at"));
    }

If you comment out AfterburnerModule, the test passes. I am using v. 2.6.3

Also tried against current master here with datatype-joda 2.7.4, and the test fails. I could publish it, but I had to mess around with some of the maven poms to get it running.

@cowtowncoder
Copy link
Member

@esiqveland Turns out this is the same problem, for what that is worth. Fix itself easy enough, but testing this with type other than Joda DateTime proving unexpectedly difficult... so not sure what the combination is. Anyway, adding notes on #7, closing this as duplicate. Thank you for the reproduction, it was necessary to actually see the issue.

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