Hessian序列化导致高CPU使用率

时间:2016-08-21 06:55:37

标签: java serialization hessian

我发现在线环境中的CPU使用率很高,几乎是2000%,系统负载非常高。以下是jstack输出(仅发布一个线程):

"http-8090-125" daemon prio=10 tid=0x0000000013e42000 nid=0x273f runnable [0x00002aead133b000]
   java.lang.Thread.State: RUNNABLE
        at com.caucho.hessian.util.IdentityIntMap.get(IdentityIntMap.java:127)
        at com.caucho.hessian.io.Hessian2Output.addRef(Hessian2Output.java:1314)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:141)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
        at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
        at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)

也在tomcat日志中发布异常:

Aug 21, 2016 4:32:56 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet products_api threw exception
java.lang.StackOverflowError
    at com.caucho.hessian.util.IdentityIntMap.get(IdentityIntMap.java:114)
    at com.caucho.hessian.io.Hessian2Output.addRef(Hessian2Output.java:1314)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:141)
    at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
    at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
    at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
    at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)
    at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:490)
    at com.caucho.hessian.io.JavaSerializer.writeObject(JavaSerializer.java:153)

我想知道是否有任何特殊的Java对象类型(数据或时间?)使得粗麻布进入无限循环,是否有人遇到过此类问题?非常感谢。

我正在使用Oracle JDK 7和Hession 3.1.5。 这是IdentityIntMap#get(Object key)

中的代码
  public int get(Object key)
  {
    int mask = _mask;
    int hash = System.identityHashCode(key) % mask & mask;

    Object []keys = _keys;

    while (true) {
      Object mapKey = keys[hash];

      if (mapKey == null)
        return NULL;
      else if (mapKey == key)
        return _values[hash];

      hash = (hash + 1) % mask;
    }
  }

0 个答案:

没有答案