DasAnirban / google-gson

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

Registering type adapters in GsonBuilder is not overwriting existing type #584

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a GsonBuilder instance & register type "ExampleSerializer" for 
"Example.class"
2. Use the object created in the #1 & then again register type 
"ExampleSerializer" for "Example.class"

What is the expected output? What do you see instead?
It should be expected that the type adapter for "Example.class" is overwritten. 
Instead new entries are created for the same type and associating it with the 
same serializer. FYI "ExampleSerializer"  implements "JsonSerializer<Example>". 

What version of the product are you using? On what operating system?
I am using Guava 14.0 library.

Please provide any additional information below.
Normally this wouldn't have been a problem but I am using the "GsonBuilder" 
object as a "static final" instance which I use across the application. And 
many times they register for the same type. Also the documentation says that if 
it's the same type then the existing registration would be overwritten (see 
here 
https://code.google.com/p/google-gson/source/browse/trunk/gson/src/main/java/com
/google/gson/GsonBuilder.java#433)

Original issue reported on code.google.com by tankchin...@gmail.com on 28 Jul 2014 at 2:43