Skip to content

Exception when deserializing ObjectIds generated by ObjectIdGenerators.UUIDGenerator #19

@fangzhen

Description

@fangzhen

Here's a simple test case that will reproduce this issue. jackson version: 2.4.0

@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "@id")
public static class D{
    public D next;
}
@Test
public void testSmileFormat() throws JsonGenerationException, JsonMappingException, IOException{
    ObjectMapper mapper = new ObjectMapper(new SmileFactory());
    D d = new D();
    d.next = d;

    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    mapper.writeValue(os, d);

    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    ObjectMapper m2 = new ObjectMapper(new SmileFactory());

    D de = m2.readValue(is, D.class);   //this will throws an exception.
}

The exception thrown are like :

com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'next' (expected type: [simple type, class JacksonTest$D]; actual type: [B), problem: Can not set JacksonTest$D field JacksonTest$D.next to [B (through reference chain: jacksonhack.D["next"]).

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions