{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/382","repository_url":"https://api.github.com/repos/FasterXML/jackson-databind","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/382/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/382/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/382","id":25214745,"number":382,"title":"@JsonIgnoreProperties fails on a property when a property value references its own bean","user":{"login":"benze","id":2797306,"avatar_url":"https://avatars.githubusercontent.com/u/2797306?v=3","gravatar_id":"","url":"https://api.github.com/users/benze","html_url":"https://github.com/benze","followers_url":"https://api.github.com/users/benze/followers","following_url":"https://api.github.com/users/benze/following{/other_user}","gists_url":"https://api.github.com/users/benze/gists{/gist_id}","starred_url":"https://api.github.com/users/benze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benze/subscriptions","organizations_url":"https://api.github.com/users/benze/orgs","repos_url":"https://api.github.com/users/benze/repos","events_url":"https://api.github.com/users/benze/events{/privacy}","received_events_url":"https://api.github.com/users/benze/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-01-08T03:56:29Z","updated_at":"2016-05-13T23:39:49Z","closed_at":"2014-02-14T01:25:44Z","body":"As per http://jackson-users.ning.com/xn/detail/5286555:Comment:30416\r\n\r\nWhen using @JsonIgnoreProperties at a property level, if a property in the bean references its own bean, the annotation is ignored.\r\n\r\nFor example:\r\n\r\nThis fails:\r\n@Entity\r\npublic class User {\r\n   long id;\r\n   String name;\r\n   String city;\r\n   ...\r\n   @JsonIgnoreProperties User createdBy;\r\n}\r\n\r\nIf createdBy references the same instance of User, a cyclic error is thrown by BeanPropertyWriter.  The following stack trace is thrown:\r\n\r\ncom.fasterxml.jackson.databind.JsonMappingException: Direct self-reference leading to cycle (through reference chain: java.util.HashMap[\"user\"]->com.ia.domain.User[\"createdBy\"])\r\nat com.fasterxml.jackson.databind.ser.BeanPropertyWriter._handleSelfReference(BeanPropertyWriter.java:740)\r\nat com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:537)\r\nat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:632)\r\nat com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)\r\nat com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFields(MapSerializer.java:467)\r\nat com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:388)\r\nat com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:27)\r\nat com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)\r\nat com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1837)\r\nat org.springframework.web.servlet.view.json.MappingJackson2JsonView.writeContent(MappingJackson2JsonView.java:302)\r\nat org.springframework.web.servlet.view.json.MappingJackson2JsonView.renderMergedOutputModel(MappingJackson2JsonView.java:257)\r\nat org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)\r\nat org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)\r\n....\r\n....\r\n\r\n\r\nThe error is generated by the cyclic check in the BeanPropertyWriter since this particular User refers to itself (ie: the createdBy value points back to itself).  The cyclic check checks to ensure that the value being serialized is not the same as the bean, and in this case, it is."},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/comments/219184164","html_url":"https://github.com/FasterXML/jackson-databind/issues/382#issuecomment-219184164","issue_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/382","id":219184164,"user":{"login":"prabhash1785","id":6193231,"avatar_url":"https://avatars.githubusercontent.com/u/6193231?v=3","gravatar_id":"","url":"https://api.github.com/users/prabhash1785","html_url":"https://github.com/prabhash1785","followers_url":"https://api.github.com/users/prabhash1785/followers","following_url":"https://api.github.com/users/prabhash1785/following{/other_user}","gists_url":"https://api.github.com/users/prabhash1785/gists{/gist_id}","starred_url":"https://api.github.com/users/prabhash1785/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prabhash1785/subscriptions","organizations_url":"https://api.github.com/users/prabhash1785/orgs","repos_url":"https://api.github.com/users/prabhash1785/repos","events_url":"https://api.github.com/users/prabhash1785/events{/privacy}","received_events_url":"https://api.github.com/users/prabhash1785/received_events","type":"User","site_admin":false},"created_at":"2016-05-13T23:39:49Z","updated_at":"2016-05-13T23:39:49Z","body":"@cowtowncoder What version of Jackson does SerializationFeature.FAIL_ON_SELF_REFERENCES have? I can't find this property here\" https://fasterxml.github.io/jackson-databind/javadoc/2.0.0/index.html?com/fasterxml/jackson/databind/ObjectWriter.html"}}