guochaiqi / google-gson

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

Thread safety issue on IBM's JDK #288

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install the latest IBM JDK (version 6)
2. Run the attached program

What is the expected output? What do you see instead?
The program starts 20 threads; each thread deserializes a JSON string into an 
object and prints out a statement to the console 1000 times. There should then 
be 20,000 lines written to the console. This code works fine on Sun's JDK and 
Apple's JDK.

On IBM's JDK, you'll see a few of the deserializations work, and then the rest 
blow up with NPE's. Here is the stack trace:
java.lang.NullPointerException
    at java.util.LinkedHashMap.get(LinkedHashMap.java:324)
    at com.google.gson.LruCache.getElement(LruCache.java:50)
    at com.google.gson.FieldAttributes.getAnnotations(FieldAttributes.java:157)
    at com.google.gson.FieldAttributes.getAnnotation(FieldAttributes.java:145)
    at com.google.gson.SerializedNameAnnotationInterceptingNamingPolicy.translateName(SerializedNameAnnotationInterceptingNamingPolicy.java:44)
    at com.google.gson.JsonObjectDeserializationVisitor.getFieldName(JsonObjectDeserializationVisitor.java:92)
    at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:97)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:158)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:131)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:73)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:51)
    at com.google.gson.Gson.fromJson(Gson.java:568)
    at com.google.gson.Gson.fromJson(Gson.java:515)
    at com.google.gson.Gson.fromJson(Gson.java:484)
    at com.google.gson.Gson.fromJson(Gson.java:434)
    at com.google.gson.Gson.fromJson(Gson.java:406)
    at com.test.GsonTest$Thready.run(GsonTest.java:32)

What version of the product are you using? On what operating system?
I've tried this with the Gson 1.5 and Gson 1.6 releases on Ubuntu 9.04 32-bit 
and Ubuntu 10.10 64-bit, and it fails both places. It works on Ubuntu and OS X 
with the Sun and Apple JDK's.

Please provide any additional information below.
Here is the reported java version information for the IBM JDK we're using:
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr9-20101125_01(SR9))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 
jvmxa6460sr9-20101124_69295 (JIT enabled, AOT enabled)
J9VM - 20101124_069295
JIT  - r9_20101028_17488ifx2
GC   - 20101027_AA)
JCL  - 20101119_01

Original issue reported on code.google.com by tobini...@gmail.com on 9 Feb 2011 at 8:33

Attachments:

GoogleCodeExporter commented 9 years ago
A fix was submitted for this in r699.

Original comment by joel.leitch@gmail.com on 14 Feb 2011 at 10:31