You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there is an reference loop in the object map, the ProtostuffIOUtil.toByteArray method will result in StackOverflowError. Following are the steps to reproduce this phenomenon.
// 1. define 2 classes, A and B, referencing each otherstaticclassA {
Bb;
Stringname;
}
staticclassB {
Aa;
Stringname;
}
publicstaticvoidmain(String[] args) {
// 2. create an object "a" and "b", with them referencing each otherAa = newA();
Bb = newB();
a.name = "a";
b.name = "b";
a.b = b;
b.a = a;
// 3. try to get byte array for object "a".Schema<A> schema = RuntimeSchema.getSchema(A.class);
LinkedBufferbuffer = LinkedBuffer.allocate(8192);
ProtostuffIOUtil.toByteArray(a, schema, buffer); // <-- this method call will result in StackOverflowError
}
Following is the top part of the error stack
Exception in thread "main" java.lang.StackOverflowError
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:358)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
at io.protostuff.runtime.RuntimeSchema.writeTo(RuntimeSchema.java:475)
at io.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:363)
at io.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:1048)
...
The text was updated successfully, but these errors were encountered:
When there is an reference loop in the object map, the
ProtostuffIOUtil.toByteArray
method will result inStackOverflowError
. Following are the steps to reproduce this phenomenon.Following is the top part of the error stack
The text was updated successfully, but these errors were encountered: