-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Avoid returning incomplete TypeAdapters in concurrent calls #1830
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
2 similar comments
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
I used the following test to verify the issue and the solution:
|
Thanks a lot for you work on this! This has now be fixed by #1832, but thank you nonetheless! |
Resolves #1829
Resolves #625 partially
In the current implementation, a
TypeAdapter
may be added to thetypeTokenCache
despite having aFutureTypeAdapter
with a null delegate as part of its definition. This would occasionally cause us to see anIllegalStateException
from GSON. This would happen when bringing up an application in a docker container and then running parallelized API tests against it. Some of the objects the application deserializes are recursively defined such asA
->B
->A
. I believe what was happening was that one thread would start to deserializeA
and call togetAdapter(A)
which would call togetAdapter(B)
which would callgetAdapter(A)
, which would return theFutureTypeAdapter
forA
. Before the first thread is able to update the delegate for theFutureTypeAdapter
forA
, another thread tries to deserializeB
, callsgetAdapter(B)
, and retrieves the entry added by the first thread which contains aTypeAdapter
forA
which is aFutureTypeAdapter
with a null delegate