简体   繁体   English

Protostuff循环引用中的RuntimeSchema?

[英]RuntimeSchema in Protostuff cyclic references?

We're using Protostuff's RuntimeSchema to serialize our data. 我们正在使用Protostuff的RuntimeSchema序列化我们的数据。 This mostly works but we sometimes get: 这通常有效,但有时我们会得到:

java.lang.StackOverflowError
at io.protostuff.runtime.ObjectSchema.mergeFrom(ObjectSchema.java:350) ~[protostuff-runtime-1.5.3.jar:1.5.3]
at io.protostuff.CodedInput.mergeObjectEncodedAsGroup(CodedInput.java:336) ~[protostuff-core-1.5.3.jar:1.5.3]
at io.protostuff.CodedInput.mergeObject(CodedInput.java:298) ~[protostuff-core-1.5.3.jar:1.5.3]
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$15$1.mergeFrom(RuntimeUnsafeFieldFactory.java:1217) ~[protostuff-runtime-1.5.3.jar:1.5.3]

This obviously means we've some sort of cyclic reference inside our objects. 显然,这意味着我们在对象内部有某种循环引用。
Reading the documentation Protostuff theoretically do support cyclic references in runtime schemas, is there a configuration I need to enable for this to work? 从理论上阅读Protostuff文档确实在运行时模式中支持循环引用,是否需要启用此配置才能使其正常工作?

I read about: Dprotostuff.runtime.collection_schema_on_repeated_fields but it's suppose to apply only to cyclic reference of array items which is not the case in our objects. 我读到以下内容: Dprotostuff.runtime.collection_schema_on_repeated_fields但它假定仅适用于数组项的循环引用,而在我们的对象中不是这种情况。

Thanks! 谢谢!

Protostuff supports multiple encoding formats ( protobuf , json and its own graph ). Protostuff支持多种编码格式( protobufjson和它自己的graph )。

If your objects contain cyclic references, then only one is suitable - graph . 如果您的对象包含循环引用,则只有一个合适的graph You can use it with io.protostuff.GraphIOUtil . 您可以将其与io.protostuff.GraphIOUtil一起io.protostuff.GraphIOUtil

Please note that other encodings ( json , protobuf ) cannot support cyclic references (it requires additional information to be included into serialized form, which is not really possible there). 请注意,其他编码( jsonprotobuf )不支持循环引用(它要求将附加信息包含在序列化形式中,但实际上这是不可能的)。

Some additional information on this topic can be found here: http://www.protostuff.io/documentation/object-graphs/ 可以在以下位置找到有关此主题的一些其他信息: http : //www.protostuff.io/documentation/object-graphs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM