Commit e2f69d04 authored by Johnny Lim's avatar Johnny Lim Committed by Phillip Webb

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
parent 2c364ceb
...@@ -192,12 +192,12 @@ class JavaBeanBinder implements BeanBinder { ...@@ -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()) { if (this.type.hasGenerics() || targetType.hasGenerics()) {
return !this.type.equals(targetType); return !this.type.equals(targetType);
} }
return this.resolvedType == null return this.resolvedType == null || !this.resolvedType.equals(resolvedType);
|| !this.resolvedType.equals(targetType.resolve());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -214,7 +214,7 @@ class JavaBeanBinder implements BeanBinder { ...@@ -214,7 +214,7 @@ class JavaBeanBinder implements BeanBinder {
return null; return null;
} }
Bean<?> bean = Bean.cached; Bean<?> bean = Bean.cached;
if (bean == null || bean.isOfDifferentType(type)) { if (bean == null || bean.isOfDifferentType(type, resolvedType)) {
bean = new Bean<>(type, resolvedType); bean = new Bean<>(type, resolvedType);
cached = bean; cached = bean;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment