DATACMNS-1828 - Fix Map component type lookup for custom Map implementations.

Instead of using the first generic type parameter of a parameterized type as Map component type, we now explicitly lookup the super type's Map-specific generics configuration and use its first generic type parameter. The same for collection like types falling back to the parameter type bound to Iterable.
This commit is contained in:
Oliver Drotbohm
2020-11-05 15:14:57 +01:00
parent 98d61d6f25
commit 9fddd402f7
3 changed files with 50 additions and 2 deletions

View File

@@ -156,6 +156,17 @@ class ParameterizedTypeInformation<T> extends ParentTypeAwareTypeInformation<T>
@Override
@Nullable
protected TypeInformation<?> doGetComponentType() {
boolean isCustomMapImplementation = isMap() && !getType().equals(Map.class);
if (isCustomMapImplementation) {
return getRequiredSuperTypeInformation(Map.class).getComponentType();
}
if (isCollectionLike() && !getType().getPackage().getName().startsWith("java.")) {
return getRequiredSuperTypeInformation(Iterable.class).getComponentType();
}
return createInfo(type.getActualTypeArguments()[0]);
}