luoxianli / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

object graph recursion with polymorphism using GraphAdapterBuilder and RuntimeTypeAdapterFactory #542

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When used in conjunction, the classes GraphAdapterBuilder and 
RuntimeTypeAdapterFactory produce an IllegalStateException "Unexpected 
recursive call to read()" on de-serialization.

When used separately, GraphAdapterBuilder can serialize and de-serialize 
circular references, and RuntimeTypeAdapterFactory can tackle classes involving 
polymorphism. When used together, serialization succeeds but de-serialization 
fails.

What steps will reproduce the problem?
Add the attached source files to a project, and execute the JUnit tests.

What is the expected output? What do you see instead?
All tests (testRecursive, testPolymorphic and testPolymorphicRecursive) in the 
attached source should pass. Instead, testPolymorphicRecursive fails with an 
exception.

What version of the product are you using? On what operating system?
Gson 2.2.4
RuntimeTypeAdapterFactory from 
https://code.google.com/p/google-gson/source/browse/trunk/extras/src/main/java/c
om/google/gson/typeadapters/RuntimeTypeAdapterFactory.java
GraphAdapterBuilder from 
https://code.google.com/p/google-gson/source/browse/trunk/extras/src/main/java/c
om/google/gson/graph/GraphAdapterBuilder.java with the changes made as 
suggested in https://code.google.com/p/google-gson/issues/detail?id=137#c12

Original issue reported on code.google.com by huny...@gmail.com on 17 Nov 2013 at 2:38

Attachments: