spring-boot/spring-boot-project
Phillip Webb 84b13f0748 Refine constructor detection logic when binding to existing values
Update `DefaultBindConstructorProvider` so that deduced constructors
are not used if there is an existing value.

Prior to this commit, constructor detection logic was not compatible
with earlier versions of Spring Boot. With Spring Boot 3.0.1, given
a class of the following form:

	@ConfigurationProperties(prefix = "example")
	public class ExampleProperties {

	    @NestedConfigurationProperty
	    private final NestedProperty nested = new NestedProperty(
	    		"Default", "default");

	    public NestedProperty getNested() {
	        return nested;
	    }

	}

If `NestedProperty` has a single constructor with arguments, constructor
binding would be used. In Spring Boot 2.x, setter injection would have
been used.

The updated code now only uses constructor injection if an explicit
`@ConstructorBinding` annotation is present, or if there is no existing
value.

Fixes gh-33409
See gh-33710
2023-01-09 16:57:56 -08:00
..
spring-boot Refine constructor detection logic when binding to existing values 2023-01-09 16:57:56 -08:00
spring-boot-actuator Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-actuator-autoconfigure Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-autoconfigure Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-dependencies
spring-boot-devtools Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-docs Add reference to Spring Authorization Server project 2023-01-09 15:26:40 +01:00
spring-boot-parent
spring-boot-starters
spring-boot-test Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-test-autoconfigure Update copyright year of changed files 2023-01-09 15:46:07 -08:00
spring-boot-tools Update copyright year of changed files 2023-01-09 15:46:07 -08:00