1

We're using Protostuff's RuntimeSchema to serialize our data. 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?

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.

Thanks!

sternr
  • 6,216
  • 9
  • 39
  • 63

1 Answers1

1

Protostuff supports multiple encoding formats (protobuf, json and its own graph).

If your objects contain cyclic references, then only one is suitable - graph. You can use it with 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).

Some additional information on this topic can be found here: http://www.protostuff.io/documentation/object-graphs/

Kostiantyn
  • 935
  • 8
  • 13