Skip to content

Resolve configured messageSource basenames ahead of discovered bundles (#11795) - #14753

Merged
jdaugherty merged 1 commit into
7.0.xfrom
issue-11795
Sep 30, 2026
Merged

jdaugherty merged 1 commit into
7.0.xfrom
issue-11795

Conversation

@jdaugherty

@jdaugherty jdaugherty commented May 17, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #11795

PluginAwareResourceBundleMessageSource.afterPropertiesSet() ended by calling setBasenames(...) with the bundles it discovered in grails-app/i18n, which replaces the array outright. Any basenames a user configured on the bean were therefore discarded and replaced by the discovery order: a raw File.listFiles() of grails-app/i18n in development, jar entry order in production. Neither order can be controlled, so a bundle meant to override keys from messages could not be made to win, and a listed bundle outside grails-app/i18n was not resolved at all. This has been the behaviour since the discovery code was added in 2014.

The fix keeps the configured basenames first, in the order given, and appends the discovered basenames that were not already listed. Nothing changes for applications that do not configure basenames.

Tests:

  • PluginAwareResourceBundleMessageSourceSpec (grails-core) drives setBasenames + afterPropertiesSet and fails 2 of 5 features without the fix.
  • ConfiguredBasenamesSpec in grails-test-examples/app1 reproduces the report in a real application: resources.groovy now defines the messageSource bean with basenames = ['overrides', 'i18n-extra/external', 'messages']. Without the fix the bean ends up with basenames=[messages,overrides] and both the override and the external bundle assertions fail.

Docs: added a paragraph to the message-bundles section describing the precedence of configured basenames over discovered bundles.

Note: this only applies to 7.0.x. On 8.x Spring Boot owns the messageSource bean and I18nEnvironmentPostProcessor already ranks the application's declared spring.messages.basename first; PluginAwareResourceBundleMessageSource no longer exists there.

@robertoschwald

robertoschwald commented May 19, 2025 •

Copy link
Copy Markdown
Contributor

See #14755

This was referenced May 19, 2025
@jamesfredley jamesfredley moved this to In Progress in Apache Grails Jul 13, 2025
jamesfredley pushed a commit that referenced this pull request Aug 18, 2025
jamesfredley added a commit that referenced this pull request Aug 18, 2025
@jamesfredley
jamesfredley marked this pull request as ready for review August 18, 2025 22:13
@jamesfredley jamesfredley linked an issue Aug 18, 2025 that may be closed by this pull request
@matrei

matrei commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

I would expect to see a failing test in ResourceBundleMessageSourceSpec after resetting the changes to PluginAwareResourceBundleMessageSource.

@jamesfredley jamesfredley removed this from the grails:7.0.0-RC2 milestone Aug 20, 2025
borinquenkid pushed a commit that referenced this pull request Jul 17, 2026
borinquenkid added a commit that referenced this pull request Jul 17, 2026
…me ordering

Directly exercises setBasenames()/afterPropertiesSet() on
PluginAwareResourceBundleMessageSource (not just the inherited
ReloadableResourceBundleMessageSource behavior the existing spec
covered), closing the coverage gap noted on PR #14753. Verified this
test fails against the pre-fix code with the exact regression
reported in #11795 (plugin bundle wins over the explicitly configured
one) and passes with the fix.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@borinquenkid

Copy link
Copy Markdown
Member

@jdaugherty I fixed it for him just take a quick look

@jamesfredley jamesfredley moved this from In Progress to Todo in Apache Grails Jul 24, 2026
@borinquenkid borinquenkid added this to the grails:7.0.15 milestone Jul 28, 2026
@testlens-app

This comment has been minimized.

PluginAwareResourceBundleMessageSource.afterPropertiesSet() replaced the
basenames configured on the bean with the bundles it discovered in
grails-app/i18n, so the configured order was lost and a configured bundle
outside that directory was never resolved. Keep the configured basenames
first, in the order given, and append the discovered ones that were not
already listed.

Fixes #11795

Co-authored-by: Walter Duque de Estrada <[email protected]>
@jdaugherty
jdaugherty merged commit a37a97e into 7.0.x Sep 30, 2026
49 of 51 checks passed
@jdaugherty

Copy link
Copy Markdown
Contributor Author

Fixes #11795

@jdaugherty
jdaugherty deleted the issue-11795 branch September 30, 2026 17:10
@jdaugherty jdaugherty changed the title #11795 preserve order of bean-defined basenames Resolve configured messageSource basenames ahead of discovered bundles (#11795) Sep 30, 2026
antobinary added a commit to antobinary/bigbluebutton that referenced this pull request Oct 5, 2026
Apache Grails tagged 8.0.0 on 2026-10-04 and opened its release vote the
same day. Until the vote closes the artifacts are in the ASF staging
group only, so the TEMP staging-repository entries in build.gradle stay
and their comments are retargeted at 8.0.0; they come out once 8.0.0 is
on Maven Central.

Against RC2 the 8.0.0 BOM changes two things: asset-pipeline goes from
5.2.0-RC3 to 5.2.0 and SiteMesh from 3.3.0-RC3 to 3.3.0. Spring Boot
(4.1.1), Groovy (5.1.3) and the Gradle version Grails builds with
(9.8.0) are unchanged, so gradle.properties only moves grailsVersion and
the cloud.wondrify asset-pipeline plugin follows the BOM to 5.2.0. The
Tomcat 11.0.26 override stays: there is still no Spring Boot 4.1 release
newer than 4.1.1.

.gitlab-ci.yml moves to bbb-build:grails-8--2026-10-04-230216, which has
the same toolchain as the previous grails-8 image (JDK 21.0.12.1,
Go 1.27.0, Node 22.23.2) with the Grails 8.0.0 CLI.

Checked, nothing to do for what went into 8.0.0 after RC2: the default
dataSource bean (apache/grails-core#16458) is registered only with GORM
for Hibernate, which bbb-web does not ship; the XML-safe GSP html codec
default (apache/grails-core#16460) is what bbb-web already configures
explicitly, and it has no GSPs; the messageSource basename ordering
(apache/grails-core#14753) has nothing to act on, bbb-web looks up no
messages through it.

Verified with a package build in the new image, installed on a 4.0 dev
container: the WAR has the same 248 jars as the RC2 build, with the 44
grails-* jars at 8.0.0 and Spring Boot 4.1.1, Tomcat 11.0.26 and Groovy
5.1.3 unchanged. bbb-web started in 7.4 s with a clean log (no ERROR,
only the logback layout/encoder WARNs the stock build prints too) and
/bigbluebutton/api returned SUCCESS. A 5.3 MB PDF uploaded through the
client became the current presentation (bbb-web counted 117 pages),
and a join inside a cross-origin iframe still rendered the client. The
api + presentation Playwright suites gave 32 passed, 7 failed and 3
skipped on the 8.0.0 build, the same counts as the stock Grails 7.0.12
build on the same container, and the per-test results were identical:
no test differed, the same 7 tests fail on both builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

resourcebundle basenames order not respected

5 participants