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 160773e52ce..99ebc054eb3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * * @author Phillip Webb * @author Madhura Bhave + * @author Yanming Zhou */ class DefaultBindConstructorProviderTests { @@ -92,6 +93,12 @@ class DefaultBindConstructorProviderTests { .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 @@ class DefaultBindConstructorProviderTests { } + static final class TypeWithPrivateConstructor { + + private TypeWithPrivateConstructor(Environment environment) { + } + + } + static class MemberTypeWithPrivateConstructor { static final class Member {