Mantis - Hessian
Viewing Issue Advanced Details
3981 major always 04-06-10 02:40 01-12-12 03:25
halid  
 
normal  
new 4.0.3  
open  
none    
none  
0003981: Java Enums Deserialization Problem
We are using Hessian 4.0.3 as HTTP-Wrapper for our RMI-Services. Since we expanded one of our main services with a new parameter that contains EnumSet and Enums, we get deserialization problems on the client site.
I analyzed the problem comparing reference-arrays on the serializer and deserializer side, and could see that the Hessian-Deserializer for EnumSets creates one more reference in his reference-array. This difference leads to deserialization problems on all following attributes that are handled as references because of changed index of reference.
I attached a small Java-Program that reproduces this problem.
Java Runtime: Sun jdk1.5.0_16
OS: Windows XP
Hessian: 4.0.3
 SerializationHessTest.java [^] (1,975 bytes) 04-06-10 02:40

Notes
(0005673)
sdabek   
01-12-12 03:25   
It seems the Hessian deserializer also tries to deserialize Enum types as Enums.

EnumSets are serialized through a SerializationProxy, which contains an array of its Enums and an "elementType" attribute storing their type. Now the Hessian deserializer tries to deserialze "elementType" with the EnumDeserializer instead of the ClassDeserializer, which obviously fails.

The following fix in SerializerFactory should handle this correctly:

Replace:
else if (Enum.class.isAssignableFrom(cl))
  deserializer = new EnumDeserializer(cl);

With:
else if (cl.isEnum())
  deserializer = new EnumDeserializer(cl);