jdaugherty commented on code in PR #16722:
URL: https://github.com/apache/grails-core/pull/16722#discussion_r4348900078
##########
grails-i18n/src/main/groovy/org/grails/plugins/i18n/I18nEnvironmentPostProcessor.java:
##########
@@ -147,12 +149,10 @@ private List<String> compose(ConfigurableEnvironment
environment, List<String> d
}
private List<String> declaredBasenames(ConfigurableEnvironment
environment) {
- String declared = environment.getProperty(BASENAME_PROPERTY);
- if (declared == null || declared.isBlank()) {
- return List.of();
- }
+ List<String> declared =
Binder.get(environment).bind(BASENAME_PROPERTY, Bindable.listOf(String.class))
Review Comment:
This fixes the case where a descriptor is on the classpath, but the early
return at line 122 (`descriptors.isEmpty()`) still loses a list-valued
`spring.messages.basename`. With no descriptor nothing is published, and Spring
Boot's `MessageSourceAutoConfiguration.ResourceBundleCondition` reads the
property with `getProperty("spring.messages.basename", "messages")`. Since
#16552 that returns null for a non-empty list, so the condition only looks for
`messages.properties`.
That is the case the comment above `addLast` describes, and the one the
guide gives as the reason to set the property ("the way to reach a bundle
outside `grails-app/i18n`"). An application with no bundles in
`grails-app/i18n`, so no descriptor is generated, and
```yaml
spring:
messages:
basename:
- config/i18n/custom
- other
```
gets no message source unless a root `messages.properties` happens to exist.
With a class loader that hides `META-INF/grails/i18n.properties`,
`environment.getProperty(BASENAME_PROPERTY, 'messages')` after this processor
runs returns `messages` for the list form and `config/i18n/custom,other` for
the comma-separated form. Before #16552 the list came back as a `List` and was
converted to the comma-separated string, so this worked.
Could the declared names be published when no descriptor is found too? For
example, read them before the `descriptors.isEmpty()` return and write the
joined value when the list is non-empty, with a feature that hides the
descriptor and asserts `environment.getProperty(BASENAME_PROPERTY, 'messages')`
returns the declared names.
--
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]