{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/921","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/921/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/921/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/921/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/921","id":105471809,"number":921,"title":"Deserialization Not Working Right with Generic Types and Builders","user":{"login":"gilbode","id":2422580,"avatar_url":"https://avatars.githubusercontent.com/u/2422580?v=3","gravatar_id":"","url":"https://api.github.com/users/gilbode","html_url":"https://github.com/gilbode","followers_url":"https://api.github.com/users/gilbode/followers","following_url":"https://api.github.com/users/gilbode/following{/other_user}","gists_url":"https://api.github.com/users/gilbode/gists{/gist_id}","starred_url":"https://api.github.com/users/gilbode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilbode/subscriptions","organizations_url":"https://api.github.com/users/gilbode/orgs","repos_url":"https://api.github.com/users/gilbode/repos","events_url":"https://api.github.com/users/gilbode/events{/privacy}","received_events_url":"https://api.github.com/users/gilbode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-08T21:21:36Z","updated_at":"2015-09-08T22:57:57Z","closed_at":null,"body":"When trying to deserialize a generic type using a builder it is deserializing the generic type as a LinkedHashMap instead of the proper type, exact same code deserialized using @JsonCreator works fine.  There seems to be something missing in the builder code.  Test case below demonstrates the problem:\r\n\r\n```\r\nimport static org.hamcrest.MatcherAssert.assertThat;\r\nimport static org.hamcrest.Matchers.hasSize;\r\nimport static org.hamcrest.Matchers.instanceOf;\r\n\r\nimport com.fasterxml.jackson.annotation.JsonCreator;\r\nimport com.fasterxml.jackson.annotation.JsonProperty;\r\nimport com.fasterxml.jackson.core.type.TypeReference;\r\nimport com.fasterxml.jackson.databind.ObjectMapper;\r\nimport com.fasterxml.jackson.databind.annotation.JsonDeserialize;\r\n\r\nimport org.junit.Test;\r\n\r\nimport java.util.List;\r\n\r\npublic class JacksonDeserTest {\r\n  public static class MyPOJO {\r\n    public String x;\r\n    public String y;\r\n\r\n    @JsonCreator\r\n    public MyPOJO(@JsonProperty(\"x\") String x, @JsonProperty(\"y\") String y) {\r\n      this.x = x;\r\n      this.y = y;\r\n    }\r\n  }\r\n\r\n  @JsonDeserialize(builder = MyGenericPOJO.Builder.class)\r\n  public static class MyGenericPOJO<T> {\r\n    private List<T> data;\r\n\r\n    private MyGenericPOJO(List<T> data) {\r\n      this.data = data;\r\n    }\r\n\r\n    public List<T> getData() {\r\n      return data;\r\n    }\r\n\r\n    public static class Builder<T> {\r\n      private List<T> data;\r\n\r\n      public Builder<T> withData(List<T> data) {\r\n        this.data = data;\r\n        return this;\r\n      }\r\n\r\n      public MyGenericPOJO<T> build() {\r\n        return new MyGenericPOJO<T>(data);\r\n      }\r\n    }\r\n  }\r\n\r\n  public static class MyGenericPOJOWithCreator<T> {\r\n    private List<T> data;\r\n\r\n    private MyGenericPOJOWithCreator(List<T> data) {\r\n      this.data = data;\r\n    }\r\n\r\n    @JsonCreator\r\n    public static <T> MyGenericPOJOWithCreator<T> create(@JsonProperty(\"data\") List<T> data) {\r\n      return new MyGenericPOJOWithCreator.Builder<T>().withData(data).build();\r\n    }\r\n\r\n    public List<T> getData() {\r\n      return data;\r\n    }\r\n\r\n    public static class Builder<T> {\r\n      private List<T> data;\r\n\r\n      public Builder<T> withData(List<T> data) {\r\n        this.data = data;\r\n        return this;\r\n      }\r\n\r\n      public MyGenericPOJOWithCreator<T> build() {\r\n        return new MyGenericPOJOWithCreator<T>(data);\r\n      }\r\n    }\r\n  }\r\n\r\n  @Test\r\n  public void testWithBuilder() throws Exception {\r\n    final ObjectMapper mapper = new ObjectMapper();\r\n    final String json = \"{ \\\"data\\\": [ { \\\"x\\\": \\\"x\\\", \\\"y\\\": \\\"y\\\" } ] }\";\r\n    final MyGenericPOJO<MyPOJO> deserialized =\r\n        mapper.readValue(json, new TypeReference<MyGenericPOJO<MyPOJO>>() {});\r\n    assertThat(deserialized.data, hasSize(1));\r\n    assertThat(deserialized.data.get(0), instanceOf(MyPOJO.class));\r\n\r\n  }\r\n\r\n  @Test\r\n  public void testWithCreator() throws Exception {\r\n    final ObjectMapper mapper = new ObjectMapper();\r\n    final String json = \"{ \\\"data\\\": [ { \\\"x\\\": \\\"x\\\", \\\"y\\\": \\\"y\\\" } ] }\";\r\n    final MyGenericPOJOWithCreator<MyPOJO> deserialized =\r\n        mapper.readValue(json, new TypeReference<MyGenericPOJOWithCreator<MyPOJO>>() {});\r\n    assertThat(deserialized.data, hasSize(1));\r\n    assertThat(deserialized.data.get(0), instanceOf(MyPOJO.class));\r\n\r\n  }\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/comments/138726168","html_url":"https://github.com/FasterXML/jackson-databind/issues/921#issuecomment-138726168","issue_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/921","id":138726168,"user":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"created_at":"2015-09-08T22:57:57Z","updated_at":"2015-09-08T22:57:57Z","body":"Getting a `LinkedHashMap` does indeed suggest that generic type is dropped, and `java.lang.Object` is assumed as the type.\r\nThank you for the test case: I hope this can be supported as expected.\r\n"}}