-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
Description
We are seeing an issue where fromJson
results in a JsonSyntaxException
with the root cause being an IllegalStateException
. The stacktrace that comes from within the GSON library is:
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.Gson.fromJson(Gson.java:927)
at com.google.gson.Gson.fromJson(Gson.java:892)
at com.google.gson.Gson.fromJson(Gson.java:841)
at com.google.gson.Gson.fromJson(Gson.java:813)
at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:66)
... 136 common frames omitted
Caused by: java.lang.IllegalStateException: null
at com.google.gson.Gson$FutureTypeAdapter.read(Gson.java:1009)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222)
... 141 common frames omitted
This seems to be due to a race condition in Gson.getAdapter
where a FutureTypeAdapter
is created by one thread and accessed by another before the delegate is set
public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) { |
edit: This looks to be well described by the comment on #625 : #625 (comment)