Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Multiple PropertySourcesPlaceholderConfigurers do not work with placeholder defaults [SPR-10240] #14873
While issue #14356 discusses this with respect to PropertyPlaceholderConfigurer, this issue specifically deals with the PropertySourcesPlaceholderConfigurer. I feel there is sufficient difference in their intended usage to warrant another ticket.
A PSPC will register the source with the environment, from which it may later be used by any number of locations requiring property lookup.
The problem is that the current implementation also processes the bean factory for every instance of PSPC that is configured. Like #14356, this causes placeholders which are not matched by the current environment to be replaced with their defaults, before later PSPCs have had a chance to load and populate the environment.
In this scenario
The issue really is that there's no way to register a property source, from within XML, without also having all placeholders processed.
There are multiple potential fixes for this, but I'm trying to illustrate there is a real problem.
The below test fails on bean2 because value == "Borked"
Affects: 3.1.4, 3.2.1
Paul Tomlin commented
Thanks Phil, I've made up a local workaround which involves using a separate namespace and a PropertySource registration mechanism.
The handler simply creates an EnvironmentAware BeanFactoryPostProcessor, which registers the resulting PropertySource with the environment. Seems to work sufficiently for my needs, I'll throw a Github project up when I have a chance.