Hessian序列化过程中Map的问题

2020-09-15  本文已影响0人  晴天哥_王志

开篇

 近期线上dubbo不停的报Hessian反序列化的警告日志,虽然不影响正常使用但作为有追求的程序员还是再一次尝试解决下,之所以说再一次是因为前一次尝试解决,但是没解决成功。

 错误信息如下,结论是在consumer端序列化了object.map对象,在provider端解析不到object这个类,有兴趣可以继续下面的分析。

WARNING: Hessian/Burlap: 'com.model.Config$1' is an unknown class in WebappClassLoader

背景

dubbo调用图
TfScoreParam tfScoreParam = new TfScoreParam(config.fetchOperations);

public class Config {
    public Map<String, Integer> fetchOperations = new HashMap<String, Integer>() {
        {
            put("CTCVR", 1);
        }
    };
}

说明:

Nov 28, 2018 5:01:07 PM com.alibaba.com.caucho.hessian.io.SerializerFactory getDeserializer
WARNING: Hessian/Burlap: 'com.model.Config$1' is an unknown class in WebappClassLoader
  context: 
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6576fe71

说明:

问题复现

复现步骤:



IDEA创建的工程A

public class DemoA {
    public Map<String, Integer> map = new HashedMap() {
        {
            put("demo",12);
        }
    };
}


public class Demo {
    public static void main(String[] args) throws Exception {
        DemoA demoA = new DemoA();
        FileOutputStream fos = new FileOutputStream(new File("F:\\hessian"));
        HessianOutput ho = new HessianOutput(fos);
        ho.writeObject(demoA.map);
        ho.flush();
        ho.close();
    }
}



IDEA创建的工程B

public class dd {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream(new File("F:\\hessian"));
        HessianInput hi = new HessianInput(fis);
        Map<String, Integer> map = (Map<String, Integer>)hi.readObject();

        System.out.println(JSON.toJSONString(map));
    }
}



复现错误信息

十一月 28, 2018 5:26:11 下午 com.caucho.hessian.io.SerializerFactory getDeserializer
警告: Hessian/Burlap: 'com.pro.DemoA$1' is an unknown class in sun.misc.Launcher$AppClassLoader@e6ea0c6:
java.lang.ClassNotFoundException: com.pro.DemoA$1
{"demo":12}

结论(猜测)

参考

Hessian/Burlap: is an unknown class in WebappClassLoader

上一篇下一篇

猜你喜欢

热点阅读