You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The recursive type variable resolution protections put into place in Gson 2.8.2 to fix #1128 does not work if a TypeVariable is referenced multiple times.
Example failing code:
enum TestEnum { ONE, TWO, THREE }
private static class TestEnumSetCollection extends SetCollection<TestEnum> {}
private static class SetCollection<T> extends BaseCollection<T, Set<T>> {}
private static class BaseCollection<U, C extends Collection<U>>
{
public C collection;
}
The enum values are unmarshaled as String instances instead of as TestEnum instances, causing ClassCastException to be raised at runtime. This is due to the fact that the visitedTypeVariables map receives an entry for T, resolves it properly, and then upon subsequent attempt to resolve T fails, since the visitedTypeVariables set indicates that T has already been resolved.
The text was updated successfully, but these errors were encountered:
The recursive type variable resolution protections put into place in Gson 2.8.2 to fix #1128 does not work if a TypeVariable is referenced multiple times.
Example failing code:
When used with the following code to unmarshal
The enum values are unmarshaled as
String
instances instead of asTestEnum
instances, causingClassCastException
to be raised at runtime. This is due to the fact that thevisitedTypeVariables
map receives an entry forT
, resolves it properly, and then upon subsequent attempt to resolveT
fails, since thevisitedTypeVariables
set indicates thatT
has already been resolved.The text was updated successfully, but these errors were encountered: