V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
junbaor
V2EX  ›  程序员

子类和父类有同样的属性,经过 hessian 序列化后值丢失是什么情况?

  •  
  •   junbaor ·
    junbaor · 2017-08-02 20:20:43 +08:00 · 2839 次点击
    这是一个创建于 2465 天前的主题,其中的信息可能已经有所发展或是发生改变。

    同事出现了这么个场景:

    子类和父类有同样的属性,经过 dubbo 调用后值丢失了
    怀疑是 hessian 序列化的问题,写了个 demo 如下:

    https://gist.github.com/junbaor/61a3a7905a390d1ca0a4dee6ed5f73fd

    经过 hessian 序列化后问题复现。

    本屌学艺不精,想不明白为什么 32 行会打印 null, 还请老司机指点

    2 条回复    2017-08-02 22:24:23 +08:00
    junbaor
        1
    junbaor  
    OP
       2017-08-02 20:23:46 +08:00
    redtea
        2
    redtea  
       2017-08-02 22:24:23 +08:00
    丢失原因: http://jameswxx.iteye.com/blog/1071476
    解决方式:序列化的方法里加上这一句 ho.setSerializerFactory(new BeanSerializerFactory());
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2187 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 05:01 · PVG 13:01 · LAX 22:01 · JFK 01:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.