• 请不要在回答技术问题时复制粘贴 AI 生成的内容
junbaor
V2EX  ›  程序员

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

  •  
  •   junbaor ·
    junbaor · Aug 2, 2017 · 3283 views
    This topic created in 3244 days ago, the information mentioned may be changed or developed.

    同事出现了这么个场景:

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

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

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

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

    2 replies    2017-08-02 22:24:23 +08:00
    redtea
        2
    redtea  
       Aug 2, 2017
    丢失原因: http://jameswxx.iteye.com/blog/1071476
    解决方式:序列化的方法里加上这一句 ho.setSerializerFactory(new BeanSerializerFactory());
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   827 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 20:38 · PVG 04:38 · LAX 13:38 · JFK 16:38
    ♥ Do have faith in what you're doing.