When serializing object whose getter use MessagePack serialization, the inner serialization breaks the outer serialization and it throws NullPointerException:
java.lang.NullPointerException
at com.fasterxml.jackson.core.util.ByteArrayBuilder.write(ByteArrayBuilder.java:224)
at org.msgpack.core.buffer.OutputStreamBufferOutput.write(OutputStreamBufferOutput.java:78)
at org.msgpack.core.buffer.OutputStreamBufferOutput.writeBuffer(OutputStreamBufferOutput.java:71)
at org.msgpack.core.MessagePacker.flushBuffer(MessagePacker.java:306)
at org.msgpack.core.MessagePacker.flush(MessagePacker.java:281)
at org.msgpack.core.MessagePacker.close(MessagePacker.java:296)
at org.msgpack.jackson.dataformat.MessagePackGenerator.close(MessagePackGenerator.java:509)
at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3911)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes(ObjectMapper.java:3244)
at org.msgpack.jackson.dataformat.MessagePackFactoryTest.testNestedSerialization(MessagePackFactoryTest.java:62)
It tries to write into ByteArrayBuilder which is already released/closed.
Reproducible using following test: (feel free to include this or derivated into msgpack tests)
@Test
public void testNestedSerialization() throws Exception
{
ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
objectMapper.writeValueAsBytes(new OuterClass());
}
public class OuterClass
{
public String getInner() throws JsonProcessingException
{
ObjectMapper m = new ObjectMapper(new MessagePackFactory());
m.writeValueAsBytes(new InnerClass());
return "EFG";
}
}
public class InnerClass
{
public String getName()
{
return "ABC";
}
}
Identical test using standard (JSON) ObjectMapper works ok - only MessagePack is affected.
When serializing object whose getter use MessagePack serialization, the inner serialization breaks the outer serialization and it throws NullPointerException:
It tries to write into ByteArrayBuilder which is already released/closed.
Reproducible using following test: (feel free to include this or derivated into msgpack tests)
Identical test using standard (JSON) ObjectMapper works ok - only MessagePack is affected.