diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java index 160773e52cef..889ada9ee823 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/DefaultBindConstructorProviderTests.java @@ -33,6 +33,7 @@ * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ class DefaultBindConstructorProviderTests { @@ -92,6 +93,12 @@ void getBindConstructorWhenHasTwoConstructorsWithBothConstructorBindingThrowsExc .withMessageContaining("has more than one @ConstructorBinding"); } + @Test + void getBindConstructorWhenIsTypeWithPrivateConstructorReturnsNull() { + Constructor constructor = this.provider.getBindConstructor(TypeWithPrivateConstructor.class, false); + assertThat(constructor).isNull(); + } + @Test void getBindConstructorWhenIsMemberTypeWithPrivateConstructorReturnsNull() { Constructor constructor = this.provider.getBindConstructor(MemberTypeWithPrivateConstructor.Member.class, @@ -224,6 +231,13 @@ static class TwoConstructorsWithBothConstructorBinding { } + static final class TypeWithPrivateConstructor { + + private TypeWithPrivateConstructor(Environment environment) { + } + + } + static class MemberTypeWithPrivateConstructor { static final class Member {