spring-projects/spring-framework — pull request #360 by vvictorlee (2013-09-25 01:02:48+00:00)
Title: Order of values in @PropertySource annotation depends on name attribute

ConfigurationClassPostProcessor parses @PropertySource annotation,
then adds each PropertySource into 'envPropertySources'.

Stack> parsedPropertySources = parser.getPropertySources();
if (!parsedPropertySources.isEmpty()) {
... some code ...
MutablePropertySources envPropertySources =
((ConfigurableEnvironment)this.environment).getPropertySources();
while (!parsedPropertySources.isEmpty()) {
envPropertySources.addLast(parsedPropertySources.pop());
}
}

ConfigurationClassPostProcessor uses 'Stack' data structure here,
the order works in LIFO. So with below configuration, 'override.properties' file is prior to 'a.properties' file.

@PropertySource(value = { "classpath:a.properties",
"classpath:override.properties" })

But CompositePropertySource uses 'ListHashSet' data structure inside,the order works in FIFO.
(CompositePropertySource is used when @PropertySource has 'name' attribute.)

To make them work same order, CompositePropertySource needs to manage
each PropertySource as list and work in LIFO.
Thank you.

Issue: SPR-10820