Mantis - Resin
Viewing Issue Advanced Details
1588 minor sometimes 01-26-07 04:15 04-06-07 15:16
closed 3.0.20  
none 3.1.1  
0001588: Hessian SerializerFactory HashMaps involved in 100% CPU infinite loop?
During load tests to HessianServlets, we've sometimes experienced that the jvm would hang with 100% cpu. Thread dumps showed many threads were busy in HashMap.get:

"http-" daemon prio=1 tid=0x465bfbd8 nid=0x64e2 runnable [0x3f371000..0x3f3721b0]
        at java.util.HashMap.get(
        at com.caucho.hessian.server.HessianSkeleton.invoke(
        at com.caucho.hessian.server.HessianServlet.service(

A look at SerializerFactory shows it uses a set of hashmaps which are not synchronized:

  private HashMap _cachedSerializerMap;
  private HashMap _cachedDeserializerMap;
  private HashMap _cachedTypeDeserializerMap;

My guess is that if a HessianServlet receives many simultaneous calls during startup (when the maps are empty), concurrent read and write to the _cachedSerializerMap could cause this behavior. If this is the case, I suggest wrapping them in synchronizers:

_cachedDeserializerMap = Collections.synchronizedMap(new HashMap(8));

I have however been unable to reproduce this in some simple tests. Maybe someone who is more familiar with the code could advise.
About infinite loops in unsynchronized HashMaps: [^]

There are no notes attached to this issue.