jdaugherty commented on code in PR #16795:
URL: https://github.com/apache/grails-core/pull/16795#discussion_r4418909573
##########
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 &&
+
!propertySources.contains(CONFIGURATION_LISTS_PROPERTY_SOURCE_NAME)) {
Review Comment:
Added the
`propertySources.contains(ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME)`
condition in 9d98b7d677, with a Javadoc paragraph saying a configurer given its
own sources resolves placeholders from those alone. The new data-driven feature
in `GrailsPlaceholderConfigurerSpec` registers the configurer with its own
sources, loads `app.names: [first, second]` and `app.scalar: single` into the
environment, and injects `${app.names:fallback}` and `${app.scalar:fallback}`.
The rows with no sources and with one unrelated `MapPropertySource` expect
`fallback` for both; a third row with a source named `environmentProperties`
among them expects `first,second` and `single`. On 40f143239e the first two
rows fail with `first,second`; all 18 features pass with the fix.
--
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]