Skip to content

Commit 4f45e74

Browse files
t-osterThomas Oster
authored andcommitted
Fix RuntimeTypeAdapterFactory
Trying to use this class as is results in the type-property not being serialized into the JSON, thus it is not present on deserialization. The fix from #712 (comment) works. No idea why this is not merged yet.
1 parent c79b6e3 commit 4f45e74

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) {
205205

206206
@Override
207207
public <R> TypeAdapter<R> create(Gson gson, TypeToken<R> type) {
208-
if (type.getRawType() != baseType) {
208+
if (null == type || !baseType.isAssignableFrom(type.getRawType())) {
209209
return null;
210210
}
211211

0 commit comments

Comments
 (0)