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

Impossible to serialize nested generic class of the same type e.g. HashMap<Long, HashMap<Long, HashMap<Long, String>>> #207

Closed
unoexperto opened this issue Apr 1, 2014 · 11 comments

Comments

@unoexperto
Copy link

How can I understand and fix cause of "Parent scope can be set just once" exception?

I have following object that I'm trying to serialize

TTHashTable<Long, TTHashTable<Long, TTHashTable<Long, TTBusObj>>>

where TTHashTable is

public class TTHashTable<K, V> extends TTBusObj {
    private Hashtable<K, V> ht;
}

exception is thrown (according to debugger) when we're trying to pass first inner Hashtable into FieldSerializer.write.

I'm using Kryo 2.23.

Thanks!

@romix
Copy link
Collaborator

romix commented Apr 1, 2014

Hi, this is most likely a problem with the way how Kryo handles very complex generic type declarations. There are some problems there.

Could you provide a self-contained test-case for your problem? Then I could look into it.

@romix romix closed this as completed Apr 1, 2014
@romix romix reopened this Apr 1, 2014
@romix
Copy link
Collaborator

romix commented Apr 1, 2014

Sorry. It was not meant to be closed. I clicked the wrong button ;-)

@unoexperto
Copy link
Author

Here we go
https://github.com/cppexpert/kryo_bug

I use SBT to create IDEA configs so you can run "sbt gen-idea" locally so that IDEA configs reference dependencies correctly

@romix
Copy link
Collaborator

romix commented Apr 1, 2014

Thanks. I'll look into it

@romix
Copy link
Collaborator

romix commented Apr 2, 2014

OK. I could reproduce a problem.

It seems like it occurs if classes are designed in such a way that the same class with generic parameters is used recursively in an object graph. In your case, it is TTHashTable<Long, TTHashTable<Long, TTHashTable<Long, TTBusObj>>> and the like. Here TTHashTable is used recursively, as you can see and each use has different values of generic parameters.

I'll see now how this can be fixed. But it may turn out that it is actually pretty complex to fix properly.

@unoexperto unoexperto changed the title How can I understand and fix cause of "Parent scope can be set just once" exception? Impossible to serialize nested generic class of the same type e.g. HashMap<Long, HashMap<Long, HashMap<Long, String>>> Apr 2, 2014
@unoexperto
Copy link
Author

I see. What the chances you could fix it in foreseeable future?

@romix
Copy link
Collaborator

romix commented Apr 2, 2014

I'll give it a try this week. But if I don't manage to fix it quickly, I'll schedule it for a later, e.g. after next release time.

romix added a commit that referenced this issue Apr 3, 2014
@romix
Copy link
Collaborator

romix commented Apr 3, 2014

Please use latest trunk (i.e. a snapshot build) and give it a try. Seems to work for me on your test-case. Close the issue, if everything is OK now.

@unoexperto
Copy link
Author

It works. Thanks a lot.

@unoexperto
Copy link
Author

romix, could you update SBT repo with new build ?

@romix
Copy link
Collaborator

romix commented Apr 14, 2014

The latest SNAPSHOT build (i.e. the latest trunk build) should be available from Sonatype (see GitHub homepage for more info).

As for the release build, I cannot do it, because we haven't released the latest version yet. But we are planning to do it pretty soon.

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

No branches or pull requests

2 participants