Skip to content

Commit e2f69d0

Browse files
izeyephilwebb
authored andcommitted
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
1 parent 2c364ce commit e2f69d0

File tree

1 file changed

+4
-4
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind

1 file changed

+4
-4
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ public BeanSupplier<T> getSupplier(Bindable<T> target) {
192192
});
193193
}
194194

195-
private boolean isOfDifferentType(ResolvableType targetType) {
195+
private boolean isOfDifferentType(ResolvableType targetType,
196+
Class<?> resolvedType) {
196197
if (this.type.hasGenerics() || targetType.hasGenerics()) {
197198
return !this.type.equals(targetType);
198199
}
199-
return this.resolvedType == null
200-
|| !this.resolvedType.equals(targetType.resolve());
200+
return this.resolvedType == null || !this.resolvedType.equals(resolvedType);
201201
}
202202

203203
@SuppressWarnings("unchecked")
@@ -214,7 +214,7 @@ public static <T> Bean<T> get(Bindable<T> bindable, boolean canCallGetValue) {
214214
return null;
215215
}
216216
Bean<?> bean = Bean.cached;
217-
if (bean == null || bean.isOfDifferentType(type)) {
217+
if (bean == null || bean.isOfDifferentType(type, resolvedType)) {
218218
bean = new Bean<>(type, resolvedType);
219219
cached = bean;
220220
}

0 commit comments

Comments
 (0)