-
Notifications
You must be signed in to change notification settings - Fork 26.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
protostuff loses the type when serializing the subtype #8742
Comments
application和version都是URL存储在Global Param Cache Table里的参数,URL.valueOf构造的URLParam不会存储这些参数,只是通过一个BitSet指向DynamicParamTable对应的index。
|
这样弄了也解决不了,你可以试下,反序列化后的值和序列化之前的值不一样 |
在我本机测试时发现,反序列化后的值的 toString 固定了,用的是 URLAddress 的属性(实际上应该要用它的子类才对) |
fooParsed.toFullString(): |
感谢,我好像明白了。 |
URL应该不是为了你这种应用场景设计的,你不需要URL,只需要一个承载URL的字符串,直接传url的字符串就好了,然后用URL.valueOf重新构造出来。
|
我是觉得应该还是要支持 URL 的序列化,在 dubbo2 中,有相关的测试用例. 现在在 dubbo3 中迁移到了 spi-extension 仓库中了。然后经过测试,发现 protostuff 对于序列化 URL 的用例跑不过 |
3.0和2.0的URL差异很大,3.0的url参数搞了个全局存储,可能是为了兼容2.0的功能,又加了个toFullString和toSerializableURL,不清楚这么搞是不是为了提高性能,但是这样做的结果就是3.0的URL根本支持不了你这种应用场景了。 |
还有一个就是3.0的URL里面的URLAddress,URLParam属性字段类型都是基类,实际使用的类型可能都是派生类,RuntimeSchema.getSchema(URL.class)这样获取的schema是搞不定原样反序列化的。 |
是的,所以我的想法是吧 RuntimeSchema.getSchema(URL.class) 这个修改 为 RuntimeSchema.getSchema(Class, DefaultIdStrategy) 为这种,但是不知道是否会影响其他类型的序列化 |
有派生类的情况下通常都需要设置这个参数,对性能有影响,如果你追求完美,还可以自定义序列化delegate |
明白了,感谢 |
我在dubbo-spi-extentsions提了个PR,可以参考一下 |
两年前提交的 apache/dubbo-spi-extensions#67 居然今天收到了fix conficts的回应,我都忘了当初提这个PR是要修复什么东西了,找到这个帖子才想起来。 |
Environment
Steps to reproduce this issue
test case:
link protostuff/protostuff#316
The text was updated successfully, but these errors were encountered: