You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "codeconsole (via GitHub)" <gi...@apache.org> on 2026/06/22 02:04:52 UTC
[PR] Make localeResolver overridable via @ConditionalOnMissingBean [grails-core]
codeconsole opened a new pull request, #15751:
URL: https://github.com/apache/grails-core/pull/15751
## What
`I18nAutoConfiguration.localeResolver()` registers the `localeResolver` bean **unconditionally**. As a result, any application- or plugin-supplied `LocaleResolver` overrides the framework default — a bean-definition override warning on startup by default, and a hard startup failure when `spring.main.allow-bean-definition-overriding=false`.
This adds `@ConditionalOnMissingBean(name = "localeResolver")` so the Grails default backs off cleanly when the application already defines one. This mirrors Spring Boot's own `WebMvcAutoConfiguration.localeResolver()`, which is `@ConditionalOnMissingBean` for exactly this reason — registering it unconditionally is the divergence.
```java
@Bean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME)
@ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME)
public LocaleResolver localeResolver() {
return new SessionLocaleResolver();
}
```
## Why keyed on the name, not the type
`DispatcherServlet` resolves the locale resolver by the fixed bean name `DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME` (`"localeResolver"`). A `LocaleResolver` bean registered under a different name is never the one actually used, so keying the condition on the bean name matches the real lookup semantics — a by-type condition could back off for an unrelated resolver bean that `DispatcherServlet` ignores.
## Scope
The sibling beans in the same class (`localeChangeInterceptor`, `messageSource`) are also registered unconditionally; this PR is intentionally scoped to `localeResolver` only. Happy to extend if maintainers prefer.
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make localeResolver overridable via @ConditionalOnMissingBean [grails-core]
Posted by "codeconsole (via GitHub)" <gi...@apache.org>.
codeconsole closed pull request #15751: Make localeResolver overridable via @ConditionalOnMissingBean
URL: https://github.com/apache/grails-core/pull/15751
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Make localeResolver overridable via @ConditionalOnMissingBean [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #15751:
URL: https://github.com/apache/grails-core/pull/15751#issuecomment-4764192824
## 🚨 TestLens detected 1 failed test 🚨
Here is what you can do:
1) Inspect the test failures carefully.
2) If you are convinced that some of the tests are flaky, you can mute them below.
3) Finally, trigger a rerun by checking the rerun checkbox.
### Test Summary
#### [CI / Functional Tests \(Java 21, indy\=false\)](https://github.com/apache/grails-core/actions/runs/27925090703/job/82625900478?pr=15751) > :grails-test-examples-app1:integrationTest
| Test | Runs |
|---|---|
| BookFunctionalSpec > Test that switching language results in correct encodings | ❌ |
🏷️ Commit: dbee13e92fef4e22a9452d56ccd87f648c8896e8
▶️ Tests: 18862 executed
🟡 Checks: 16/38 completed
### Test Failures
<details>
<summary><strong>BookFunctionalSpec > Test that switching language results in correct encodings</strong> (:grails-test-examples-app1:integrationTest in <a href="https://github.com/apache/grails-core/actions/runs/27925090703/job/82625900478?pr=15751">CI / Functional Tests (Java 21, indy=false)</a>)</summary>
```
Condition not satisfied:
page.createButton.text() == 'Book anlegen'
| | | |
| | | false
| | | 11 differences (8% similarity)
| | | (New-) (Book---)
| | | (Book) (anlegen)
| | New Book
| functionaltests.pages.BookShowPage -> createButton: geb.navigator.DefaultNavigator
functionaltests.pages.BookShowPage
at functionaltests.BookFunctionalSpec.Test that switching language results in correct encodings(BookFunctionalSpec.groovy:48)
```
|expected|actual|
|---|---|
|<s>Book</s> <s>anlegen</s>|<b>New</b> <b>Book</b>|
</details>
### Muted Tests
> [!NOTE]
> Checks are currently running using the configuration below.
Select tests to mute in this pull request:
🔲 BookFunctionalSpec > Test that switching language results in correct encodings <!-- uniqueId=[engine:spock]/[spec:functionaltests.BookFunctionalSpec]/[feature:$spock_feature_1_2] -->
Reuse successful test results:
🔲 ♻️ Only rerun the tests that failed or were muted before
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
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: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org