Mantis - Hessian
Viewing Issue Advanced Details
4565 major always 05-19-11 02:07 05-19-11 02:07
0004565: Hibernate PersistentMap serialization broken (again)
With Resin/Hessian 4.0.18 serialization of Hibernate PersistentMap:s is broken (again) in some situations.

If the PersistentMap is the "top" return value, it seems to work fine. However if the PersistentMap is part of another structure, such as the value in a HashMap that is returned, it is serialized as being of type java.lang.Object

Please add a test case for this in your internal suite.
Example test case:

    final Map<String, String> persistentMap = ...
    assertEquals(PersistentMap.class, persistentMap.getClass());
    assertSize(2, persistentMap);
    SortedMap<Integer, Map<String, String>> input = new TreeMap<Integer, Map<String, String>>();
    input.put(1, persistentMap);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    sendToStream(baos, input);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    Map result = readFromStream(bais, SortedMap.class);
    assertEquals(TreeMap.class, result.getClass());
    assertEquals(input, result);

  private static void sendToStream(OutputStream os, Object value) throws Throwable {
    HessianDebugOutputStream dos = new HessianDebugOutputStream(os, new PrintWriter(System.out));
    Hessian2Output out = new Hessian2Output(dos);
  private static <E> E readFromStream(InputStream is, Class<E> clazz) throws Throwable {
    new HessianInputFactory().readHeader(is);
    is = new HessianDebugInputStream(is, new PrintWriter(System.out));
    Hessian2Input in = new Hessian2Input(is);
    return (E) in.readReply(clazz);

The output of the debug output stream is:
Hessian 2.0
  map java.util.TreeMap (0)
    1 => map java.lang.Object (0000001)
           "foo1" => "bar1"
           "foo2" => "bar2"

The exception is unexpected object java.lang.String (TXT)

There are no notes attached to this issue.