Closed as not planned
Description
Hello friends. While upgrading to spring-boot v3.2.0, I believe I found a regression in the binding of properties to a List<org.springframework.core.io.Resource>
. A small sample will demonstrate:
@SpringBootApplication
@EnableConfigurationProperties(CoolConfigProperties.class)
public class SampleApp {
public static void main(String[] args) {
SpringApplication.run(SampleApp.class, args);
}
}
@ConfigurationProperties(prefix = "cool")
record CoolConfigProperties(List<Resource> resources) {}
For this example, we will set an environment variable COOL_RESOURCES=classpath:foo.properties,file:./bar.properties
.
Resources are bound to ConfigurationProperties as expected when running with spring-boot v3.1.6:
However spring-boot v3.2.0 will fail to start:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.0)
2023-11-26T23:17:14.625-05:00 INFO 32744 --- [ main] com.example.SampleApp : Starting SampleApp using Java 21.0.1 with PID 32744 (C:\Users\groat\Desktop\list-property-sample\target\classes started by groat in C:\Users\groat\Desktop\list-property-sample)
2023-11-26T23:17:14.628-05:00 INFO 32744 --- [ main] com.example.SampleApp : No active profile set, falling back to 1 default profile: "default"
2023-11-26T23:17:14.854-05:00 WARN 32744 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'cool-com.example.CoolConfigProperties': Could not bind properties to 'CoolConfigProperties' : prefix=cool, ignoreInvalidFields=false, ignoreUnknownFields=true
2023-11-26T23:17:14.857-05:00 INFO 32744 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-11-26T23:17:14.866-05:00 ERROR 32744 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'cool.resources' to java.util.List<org.springframework.core.io.Resource>:
Property: cool.resources
Value: "classpath:/foo.properties,file:./bar.properties"
Origin: System Environment Property "COOL_RESOURCES"
Reason: failed to convert java.lang.String to java.util.List<org.springframework.core.io.Resource> (caused by java.lang.IllegalArgumentException: Cannot convert value of type 'java.lang.String' to required type 'java.util.List': PropertyEditor [org.springframework.core.io.support.ResourceArrayPropertyEditor] returned inappropriate value of type 'org.springframework.core.io.ClassPathResource')
Action:
Update your application's configuration
Process finished with exit code 1