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 f4c8acc08d..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, - Class resolvedType) { - if (this.type.hasGenerics() || targetType.hasGenerics()) { - return !this.type.equals(targetType); - } - return this.resolvedType == null || !this.resolvedType.equals(resolvedType); - } - @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, resolvedType)) { + 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 {