Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
class Document {}
class Row {}
class RowWithDoc<D extends Document> extends Row
{ @JsonProperty("d") D d; }class ResultSet<R extends Row>
{ @JsonProperty("rows") List<R> rows; }class ResultSetWithDoc<D extends Document> extends ResultSet<RowWithDoc<D>> {}
class MyDoc extends Document {}
public class JacksonTest {
@Test
public void shouldWork() throws JsonParseException, JsonMappingException, IOException {
String json = "{\"rows\":[{\"d\":{}}]}";
ResultSetWithDoc<MyDoc> rs = new ObjectMapper().readValue(json, new TypeReference<ResultSetWithDoc<MyDoc>>() {});
Document d = rs.rows.iterator().next().d;
Assert.assertEquals(MyDoc.class, d.getClass()); //expected MyDoc but was Document
}
}
Added unit test – not sure why type is not properly detected as subtype, strongly suspect type aliasing (for which we already also have JACKSON-743).