Skip to content
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

Circular field-types #8

Closed
GoogleCodeExporter opened this issue Mar 10, 2016 · 2 comments
Closed

Circular field-types #8

GoogleCodeExporter opened this issue Mar 10, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Hello

I'm just investigating alternativs for java serialization. We are using
SpringHTTPInvoker to transmit objects. After it seems everything should run
now. I run into a Stackoverflow during serialisation. We have a quite
complex entity-structure where it is possible to navigate forth and back
through the object tree. When I look at the stacktrace I would say the
repeating fieldtypes are the problem.

java.lang.StackOverflowError
    at java.lang.reflect.AccessibleObject.<init>(AccessibleObject.java:137)
    at java.lang.reflect.Field.<init>(Field.java:104)
    at java.lang.reflect.Field.copy(Field.java:127)
    at java.lang.reflect.ReflectAccess.copyField(ReflectAccess.java:122)
    at sun.reflect.ReflectionFactory.copyField(ReflectionFactory.java:289)
    at java.lang.Class.copyFields(Class.java:2739)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSer
ializer.java:65)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.<init>(FieldSerializer.java:
52)
    at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSer
ializer.java:100)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.<init>(FieldSerializer.java:
52)
    at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSer
ializer.java:100)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.<init>(FieldSerializer.java:
52)
    at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSer
ializer.java:100)
    at
com.esotericsoftware.kryo.serialize.FieldSerializer.<init>(FieldSerializer.java:
52)
    at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
<snip>

I'm wondering if kryo would have the same problem with repeated objects and
circular references.
Maybee an IdentiyHashMap would solve this during processing the fields.

Cheers
Marco

What version of the product are you using? On what operating system?
Windows Kryo 0.99

Please provide any additional information below.


Original issue reported on code.google.com by m.br...@gmx.de on 1 Mar 2010 at 8:08

@GoogleCodeExporter
Copy link
Author

Hi Marco,

FieldSerializer is the default serializer used for most objects (see
Kryo#register(Class) and Kryo#getDefaultSerializer(Class)). It does not support
object references. Any objects in the graph more than once will be serialized
individually more than once. Circular references will cause a stack overflow.

If you would like to serialize object references in your object graph, register 
your
classes using ReferenceFieldSerializer. Please see the javadocs for that class 
for
notes about the additional overhead it introduces. You may override
Kryo#getDefaultSerializer(Class) as an easy way to use ReferenceFieldSerializer 
for
all your classes without having to construct and pass in a new
ReferenceFieldSerializer each time you call Kryo#register.

You may be interested in the discussion thread that caused 
ReferenceFieldSerializer
to be added to Kryo. The thread is on the discussion forum for KryoNet, a sister
project that does NIO-based TCP and UDP network communication:
http://groups.google.com/group/kryonet-users/browse_thread/thread/84235dbe943ada
71#e08daae3f56e2785

Original comment by nathan.s...@gmail.com on 1 Mar 2010 at 8:26

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

Issue 41 has been merged into this issue.

Original comment by nathan.s...@gmail.com on 8 Mar 2011 at 10:47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant