Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004565 [Hessian] major always 05-19-11 02:07 05-19-11 02:07
Reporter mate View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version
Summary 0004565: Hibernate PersistentMap serialization broken (again)
Description 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.
Additional Information 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));
    dos.startTop2();
    Hessian2Output out = new Hessian2Output(dos);
    out.getSerializerFactory().setSendCollectionType(false);
    out.writeReply(value);
    out.close();
    os.close();
  }
  
  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
Reply
  map java.util.TreeMap (0)
    1 => map java.lang.Object (0000001)
           "foo1" => "bar1"
           "foo2" => "bar2"


The exception is
com.caucho.hessian.io.HessianProtocolException: com.caucho.hessian.io.BasicDeserializer: unexpected object java.lang.String (TXT)
    at com.caucho.hessian.io.AbstractDeserializer.error(AbstractDeserializer.java:150)
    at com.caucho.hessian.io.AbstractDeserializer.readMap(AbstractDeserializer.java:102)
    at com.caucho.hessian.io.SerializerFactory.readMap(SerializerFactory.java:516)
    at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2110)
    at com.caucho.hessian.io.MapDeserializer.readMap(MapDeserializer.java:114)
    at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1695)
    at com.caucho.hessian.io.Hessian2Input.readReply(Hessian2Input.java:370)
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
05-19-11 02:07 mate New Issue
05-19-11 02:08 mate Issue Monitored: mate


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker