diff --git a/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java b/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java index 762d567ef..8c6f62908 100644 --- a/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java +++ b/src/main/java/org/springframework/data/util/ParameterizedTypeInformation.java @@ -166,7 +166,20 @@ class ParameterizedTypeInformation extends ParentTypeAwareTypeInformation @Override @SuppressWarnings("unchecked") public TypeInformation specialize(ClassTypeInformation type) { - return isResolvedCompletely() ? (TypeInformation) type : super.specialize(type); + + if (isResolvedCompletely()) { + return (TypeInformation) type; + } + + TypeInformation asSupertype = type.getSuperTypeInformation(getType()); + + if (asSupertype == null || !ParameterizedTypeInformation.class.isInstance(asSupertype)) { + return super.specialize(type); + } + + return ((ParameterizedTypeInformation) asSupertype).isResolvedCompletely() // + ? (TypeInformation) type // + : super.specialize(type); } /* diff --git a/src/main/java/org/springframework/data/util/TypeDiscoverer.java b/src/main/java/org/springframework/data/util/TypeDiscoverer.java index aad143b30..8ef54480a 100644 --- a/src/main/java/org/springframework/data/util/TypeDiscoverer.java +++ b/src/main/java/org/springframework/data/util/TypeDiscoverer.java @@ -485,13 +485,15 @@ class TypeDiscoverer implements TypeInformation { @SuppressWarnings("unchecked") public TypeInformation specialize(ClassTypeInformation type) { + Assert.notNull(type, "Type must not be null!"); Assert.isTrue(getType().isAssignableFrom(type.getType()), - String.format("%s must be assignable from %s", getType(), type.getType())); + () -> String.format("%s must be assignable from %s", getType(), type.getType())); - List> arguments = getTypeArguments(); + List> typeArguments = getTypeArguments(); - return (TypeInformation) (arguments.isEmpty() ? type - : createInfo(new SyntheticParamterizedType(type, arguments))); + return (TypeInformation) (typeArguments.isEmpty() // + ? type // + : type.createInfo(new SyntheticParamterizedType(type, getTypeArguments()))); } @Nullable