-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix a class loading deadlock involving TypeAdapters
.
#2740
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
Fix a class loading deadlock involving TypeAdapters
.
#2740
Conversation
Thanks a lot for noticing and troubleshooting this! It was also my fault for not paying attention to this during the refactoring. In addition to your changes here, we could probably make it even safer by removing the public static final TypeAdapterFactory JSON_ELEMENT_FACTORY =
newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT); That would then completely remove the direct cyclic dependency between (Also, at least in my opinion, we could also un-deprecate the fields in |
The idea was to discourage people from using these, but they have been there for a long time and the deprecation isn't going to have much effect. Meanwhile the deprecation required `@SuppressWarnings`, which was annoying. Also move `JsonElementTypeFactory.ADAPTER` back into `TypeAdapters` so there is no further circular dependency between the two classes. I think it was harmless but it's easy enough to avoid.
Thanks @Marcono1234, those changes seem reasonable. |
@Deprecated | ||
public static final TypeAdapterFactory JSON_ELEMENT_FACTORY = JsonElementTypeAdapter.FACTORY; | ||
public static final TypeAdapterFactory JSON_ELEMENT_FACTORY = | ||
TypeAdapters.newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really minor: You can omit the TypeAdapters.
qualifier here (unless you added it intentionally) since this is already within TypeAdapters
.
TypeAdapters.newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT); | |
newTypeHierarchyFactory(JsonElement.class, JSON_ELEMENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this wasn't actually that complicated, but I needed to find a minute when I wasn't half-thinking about something else at the time.
Fixes #2739.