-
Notifications
You must be signed in to change notification settings - Fork 324
Closed
Description
Hello,
It seems that map serialization fails when Map contains an Object values. Here is the full stack trace and the code that is causing this error:
org.msgpack.MessageTypeException: Cannot find template for class java.lang.Object class. Try to add @message annotation to the class or call MessagePack.register(Type).
at org.msgpack.template.TemplateRegistry.lookup(TemplateRegistry.java:220)
at org.msgpack.template.TemplateRegistry.lookupGenericTypeImpl(TemplateRegistry.java:258)
at org.msgpack.template.TemplateRegistry.lookupGenericType(TemplateRegistry.java:230)
at org.msgpack.template.TemplateRegistry.lookup(TemplateRegistry.java:180)
package com.mycompany.app;
import org.junit.Test;
import org.msgpack.MessagePack;
import org.msgpack.annotation.Message;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
/**
* Verifies whether object that contains map string -> object could be serialized.
*/
public class SerializeEntityWithMapTest {
@Message
public static class Entity {
public String name;
public Map<String, Object> properties = new HashMap<String, Object>();
}
@Test
public void happyPath() throws IOException {
MessagePack pack = new MessagePack();
Entity e = new Entity();
e.name = "test";
e.properties.put("Test","aaaa");
byte[] content = pack.write(e);
Entity actual = new MessagePack().read(content, Entity.class);
System.out.println(actual.properties);
assertEquals(1,actual.properties.size());
}
}
Metadata
Metadata
Assignees
Labels
No labels