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

fromJson intermittently fails with IllegalStateException when deserializing recursive structures in parallel #1829

Closed
mwalkerr opened this issue Dec 1, 2020 · 3 comments
Labels

Comments

@mwalkerr
Copy link

mwalkerr commented Dec 1, 2020

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)

@Marcono1234
Copy link
Collaborator

This appears to be the same issue as #625

@mwalkerr mwalkerr changed the title fromJson intermittently fails with IllegalStateException fromJson intermittently fails with IllegalStateException when deserializing recursive structures in parallel Dec 2, 2020
@mwalkerr
Copy link
Author

mwalkerr commented Dec 2, 2020

This appears to be the same issue as #625

@Marcono1234 I believe you're right, thank you for linking that. Wish I would have found that sooner!

@Marcono1234 Marcono1234 added the bug label Aug 5, 2022
@Marcono1234
Copy link
Collaborator

This should be fixed by #1832, which will be available in the next release

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

Successfully merging a pull request may close this issue.

2 participants