Use actual resolvedType when checking Binder cache

Update `JavaBeanBinder` so that the `isOfDifferentType` method checks
both the actual type and the resolved type. Prior to this commit, it
was possible that when `canCallGetValue` is `true` the `resolvedType`
could be different from `type.resolve`.

Closes gh-16974
This commit is contained in:
Johnny Lim
2019-05-27 13:38:54 +09:00
committed by Phillip Webb
parent 2c364ceb89
commit e2f69d040a

View File

@@ -192,12 +192,12 @@ class JavaBeanBinder implements BeanBinder {
});
}
private boolean isOfDifferentType(ResolvableType targetType) {
private boolean isOfDifferentType(ResolvableType targetType,
Class<?> resolvedType) {
if (this.type.hasGenerics() || targetType.hasGenerics()) {
return !this.type.equals(targetType);
}
return this.resolvedType == null
|| !this.resolvedType.equals(targetType.resolve());
return this.resolvedType == null || !this.resolvedType.equals(resolvedType);
}
@SuppressWarnings("unchecked")
@@ -214,7 +214,7 @@ class JavaBeanBinder implements BeanBinder {
return null;
}
Bean<?> bean = Bean.cached;
if (bean == null || bean.isOfDifferentType(type)) {
if (bean == null || bean.isOfDifferentType(type, resolvedType)) {
bean = new Bean<>(type, resolvedType);
cached = bean;
}