TypeVariablesVariableResolver compares variables by name
Issue: SPR-16456
This commit is contained in:
@@ -1468,8 +1468,7 @@ public class ResolvableType implements Serializable {
|
||||
@Nullable
|
||||
public ResolvableType resolveVariable(TypeVariable<?> variable) {
|
||||
for (int i = 0; i < this.variables.length; i++) {
|
||||
if (ObjectUtils.nullSafeEquals(SerializableTypeWrapper.unwrap(this.variables[i]),
|
||||
SerializableTypeWrapper.unwrap(variable))) {
|
||||
if (ObjectUtils.nullSafeEquals(this.variables[i].getName(), variable.getName())) {
|
||||
return this.generics[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1337,6 +1337,14 @@ public class ResolvableTypeTests {
|
||||
assertTrue(setClass.isAssignableFrom(fromReturnType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpr16456() throws Exception {
|
||||
ResolvableType genericType = ResolvableType.forField(
|
||||
UnresolvedWithGenerics.class.getDeclaredField("set")).asCollection();
|
||||
ResolvableType type = ResolvableType.forClassWithGenerics(ArrayList.class, genericType.getGeneric());
|
||||
assertThat(type.resolveGeneric(), equalTo(Integer.class));
|
||||
}
|
||||
|
||||
|
||||
private ResolvableType testSerialization(ResolvableType type) throws Exception {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
@@ -1637,4 +1645,10 @@ public class ResolvableTypeTests {
|
||||
public Collection<IBase<BT>> stuff;
|
||||
}
|
||||
|
||||
|
||||
public abstract class UnresolvedWithGenerics {
|
||||
|
||||
Set<Integer> set;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user