jamesfredley commented on code in PR #16795:
URL: https://github.com/apache/grails-core/pull/16795#discussion_r4417471628
##########
grails-core/src/main/groovy/org/grails/spring/context/support/GrailsPlaceholderConfigurer.java:
##########
@@ -78,6 +92,34 @@ public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
+ @Override
+ public void setEnvironment(Environment environment) {
+ super.setEnvironment(environment);
+ this.environment = environment;
+ }
+
+ /**
+ * Resolves a placeholder that names a list of plain values, such as
{@code ${app.names}}, to the
+ * elements of the list joined by commas, when neither the environment nor
the local properties have
+ * a value under that name.
+ *
+ * <p>The environment presents a configuration list only under its indexed
names, such as
+ * {@code app.names[0]}, so that Spring Boot binds it element by element.
The list is read as Spring
+ * Boot binds it, from the property source of the highest priority that
sets it, and the placeholders
+ * in its elements are resolved with the rest of the value. The name is
matched as
+ * {@code @ConfigurationProperties} binding matches it, so {@code
${app.allowedOrigins}} and
+ * {@code ${app.allowed-origins}} read the same list. A list holding
objects has no value a
+ * placeholder could be replaced with, so a placeholder naming it is not
resolved.</p>
+ */
+ @Override
+ protected ConfigurablePropertyResolver
createPropertyResolver(MutablePropertySources propertySources) {
+ if (this.environment instanceof ConfigurableEnvironment
configurableEnvironment &&
Review Comment:
`createPropertyResolver` still adds a `ConfigurationListPropertySource` for
`this.environment` after `setPropertySources` has selected the sources. With an
environment list `app.names[0]=first` and an explicitly empty source list,
`${app.names:fallback}` returns `first,second` instead of `fallback`. Add that
source only when the environment is one of the selected sources.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]