{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1226","repository_url":"https://api.github.com/repos/FasterXML/jackson-databind","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1226/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1226/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1226/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/1226","id":154259096,"number":1226,"title":"@JsonIgnore has no effect when using Lombok @Getter","user":{"login":"sivasankariit","id":512726,"avatar_url":"https://avatars.githubusercontent.com/u/512726?v=3","gravatar_id":"","url":"https://api.github.com/users/sivasankariit","html_url":"https://github.com/sivasankariit","followers_url":"https://api.github.com/users/sivasankariit/followers","following_url":"https://api.github.com/users/sivasankariit/following{/other_user}","gists_url":"https://api.github.com/users/sivasankariit/gists{/gist_id}","starred_url":"https://api.github.com/users/sivasankariit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivasankariit/subscriptions","organizations_url":"https://api.github.com/users/sivasankariit/orgs","repos_url":"https://api.github.com/users/sivasankariit/repos","events_url":"https://api.github.com/users/sivasankariit/events{/privacy}","received_events_url":"https://api.github.com/users/sivasankariit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-05-11T14:34:27Z","updated_at":"2016-09-15T11:05:56Z","closed_at":null,"body":"When using the `@Getter` lombok annotation on a class along with `@JsonIgnore` on class fields, the `@JsonIgnore` has no effect during serialization. This is a change in behavior when upgrading from jackson-databind v2.6.4 to v.2.7.4. I've added a sample test case below with the serialized outputs in each case.\r\n\r\n```\r\nimport org.testng.annotations.Test;\r\n\r\nimport com.fasterxml.jackson.annotation.JsonIgnore;\r\nimport com.fasterxml.jackson.annotation.JsonProperty;\r\nimport com.fasterxml.jackson.core.util.DefaultIndenter;\r\nimport com.fasterxml.jackson.core.util.DefaultPrettyPrinter;\r\nimport com.fasterxml.jackson.databind.ObjectMapper;\r\nimport com.fasterxml.jackson.databind.ObjectWriter;\r\n\r\nimport lombok.AllArgsConstructor;\r\nimport lombok.Getter;\r\nimport lombok.SneakyThrows;\r\n\r\n/**\r\n * Test that shows the difference between serialization with jackson-databind v2.6.4 vs v2.7.4\r\n *\r\n * <pre>\r\n *     With v2.6.4:\r\n *     {\r\n *         \"fieldB\" : \"b1\",\r\n *         \"a\" : \"a1\"\r\n *     }\r\n *\r\n *     With v2.7.4:\r\n *     {\r\n *         \"fieldA\" : \"a1\",\r\n *         \"fieldB\" : \"b1\",\r\n *         \"a\" : \"a1\"\r\n *     }\r\n * </pre>\r\n */\r\npublic class SimpleTest {\r\n\r\n    @AllArgsConstructor\r\n    @Getter\r\n    private static class Obj {\r\n\r\n        @JsonIgnore\r\n        private final String fieldA;\r\n\r\n        @JsonProperty\r\n        private final String fieldB;\r\n\r\n        @JsonProperty(\"a\")\r\n        private String getFieldAStr() {\r\n            return fieldA;\r\n        }\r\n    }\r\n\r\n    @Test\r\n    @SneakyThrows\r\n    public void testSerDes() {\r\n        Obj o1 = new Obj(\"a1\", \"b1\");\r\n\r\n        ObjectMapper mapper = new ObjectMapper();\r\n        DefaultPrettyPrinter pp = new DefaultPrettyPrinter();\r\n        pp.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);\r\n        pp.indentObjectsWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);\r\n        ObjectWriter writer = mapper.writer().with(pp);\r\n\r\n        String str = writer.writeValueAsString(o1);\r\n        System.out.println(str);\r\n    }\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/comments/247299175","html_url":"https://github.com/FasterXML/jackson-databind/issues/1226#issuecomment-247299175","issue_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1226","id":247299175,"user":{"login":"romansergey","id":1127845,"avatar_url":"https://avatars.githubusercontent.com/u/1127845?v=3","gravatar_id":"","url":"https://api.github.com/users/romansergey","html_url":"https://github.com/romansergey","followers_url":"https://api.github.com/users/romansergey/followers","following_url":"https://api.github.com/users/romansergey/following{/other_user}","gists_url":"https://api.github.com/users/romansergey/gists{/gist_id}","starred_url":"https://api.github.com/users/romansergey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romansergey/subscriptions","organizations_url":"https://api.github.com/users/romansergey/orgs","repos_url":"https://api.github.com/users/romansergey/repos","events_url":"https://api.github.com/users/romansergey/events{/privacy}","received_events_url":"https://api.github.com/users/romansergey/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T11:05:56Z","updated_at":"2016-09-15T11:05:56Z","body":"I've experienced the same issue with 2.7.3. Employing `@JsonIgnoreProperties` on class level instead of `@JsonIgnore` helped work around it.\r\n\r\n@cowtowncoder is that an expected change in behavior?"}}
{"actor":{"display_login":"romansergey"}}