Affects: Spring 6.0.9
Due to an migration of our company application configurations we experience a rather strange issue when applying environement variables in different cases: In our setting we have two variables with nearly the same content but with slightly different names e.g.
some_env_VARIABLE
and some_env_variable
. We are only trying to read one of these variables but in some cases our application fails to start.
Example application:
@SpringBootApplication
public class DemoApplication {
@Value("${some_env_VARIABLE}")
String value;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
When started with environment some_env_VARIABLE=bla
this application runs as expected.
When another environment variable is added some_env_VARIABLE=bla;some_env_variable=bla
the application fails to start:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'some_env_VARIABLE' in value "${some_env_VARIABLE}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) ~[spring-core-6.0.9.jar:6.0.9]
I could only reproduce this isse with environment variables. When using application properties the application still starts.
I've created a small sample application for reproduction issues: https://github.com/srcimon/spring-issue-duplicate-env
Comment From: srcimon
Sorry, not a Spring Framework issue. Actually a Windows / Java problem.