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

Annotation bundles ignored when added to Mixin #771

Closed
andrewduckett opened this issue Apr 24, 2015 · 2 comments
Closed

Annotation bundles ignored when added to Mixin #771

andrewduckett opened this issue Apr 24, 2015 · 2 comments
Milestone

Comments

@andrewduckett
Copy link

When updating from v 2.4.4 to 2.5.* it appears as though annotation bundles created with @JacksonAnnotationsInside are ignored when placed on a mixin. Moving the annotation bundel to the actual class seems to resolve the issue. Below is a simple test that attempts to rename a property. I have more complicated test cases that are also failing but this should provide some context.

public class Fun {

    @Test
    public void test() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper().addMixIn(Foo.class, FooMixin.class);
        String result = mapper.writeValueAsString(new Foo("result"));
        Assert.assertEquals("{\"bar\":\"result\"}", result);
    }

    @Target(value={ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD })
    @Retention(value=RetentionPolicy.RUNTIME)
    @JacksonAnnotationsInside
    @JsonProperty("bar")
    public @interface ExposeStuff {

    }

    public abstract class FooMixin {
        @ExposeStuff
        public abstract String getStuff();
    }

    public class Foo {

        private String stuff;

        Foo(String stuff) {
            this.stuff = stuff;
        }

        public String getStuff() {
            return stuff;
        }
    }
}

I'm expecting the "stuff" property to be serialized as "bar".

I apologize I haven't been able to identify the culprit (and perhaps it's in my usage). Let me know your thoughts. I'm always happy to provide more details!

@cowtowncoder
Copy link
Member

That certainly sounds like a bug. Thank you for reporting this!

@cowtowncoder
Copy link
Member

Found the problem at the bowels of code. A simple mismatch in state of a return boolean value in one place... interesting that such a simple case was not being tested, although bundles are tested as well as basic mix-ins. Just not combination thereof.

Thank you for reporting this; will be in 2.5.4, 2.6.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