diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java index c307c3a56a..65dbcb2910 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java @@ -192,14 +192,6 @@ class JavaBeanBinder implements BeanBinder { }); } - private boolean isOfDifferentType(ResolvableType targetType) { - if (this.type.hasGenerics() || targetType.hasGenerics()) { - return !this.type.equals(targetType); - } - return this.resolvedType == null - || !this.resolvedType.equals(targetType.resolve()); - } - @SuppressWarnings("unchecked") public static Bean get(Bindable bindable, boolean canCallGetValue) { ResolvableType type = bindable.getType(); @@ -214,7 +206,7 @@ class JavaBeanBinder implements BeanBinder { return null; } Bean bean = Bean.cached; - if (bean == null || bean.isOfDifferentType(type)) { + if (bean == null || !bean.isOfType(type, resolvedType)) { bean = new Bean<>(type, resolvedType); cached = bean; } @@ -234,6 +226,13 @@ class JavaBeanBinder implements BeanBinder { } } + private boolean isOfType(ResolvableType type, Class resolvedType) { + if (this.type.hasGenerics() || type.hasGenerics()) { + return this.type.equals(type); + } + return this.resolvedType != null && this.resolvedType.equals(resolvedType); + } + } private static class BeanSupplier implements Supplier {