Skip to content

Accept list syntax for spring.messages.basename - #52904

Open
sonic8-8 wants to merge 1 commit into
spring-projects:4.0.xfrom
sonic8-8:messages-basename-list
Open

sonic8-8 wants to merge 1 commit into
spring-projects:4.0.xfrom
sonic8-8:messages-basename-list

Conversation

@sonic8-8

Copy link
Copy Markdown

MessageSourceAutoConfiguration.ResourceBundleCondition reads spring.messages.basename with Environment.getProperty. With list syntax, spring.messages.basename has no value:

spring:
  messages:
    basename:
      - i18n/messages

The YAML list produces the key spring.messages.basename[0]. The condition then looks for the default messages bundle. If that bundle does not exist, MessageSourceAutoConfiguration does not define a MessageSource. The application context cannot resolve messages from i18n/messages. MessageSourceProperties.basename has been a List<String> since #42478.

The condition now binds spring.messages.basename as a List<String> with Binder. EmbeddedLdapCondition binds spring.ldap.embedded.base-dn the same way. Binder still splits a comma-separated value into entries. A comma inside an indexed entry stays part of that entry. The condition skips blank entries. It trims other entries before resource lookup. Each class loader's cache now uses the bound list as its key.

MessageSourceAutoConfigurationTests has three new tests:

  • testMultipleMessageSourceCreatedWithIndexedBasename sets two indexed entries. It fails on 4.0.x.
  • testMessageSourceCreatedWithCommaInIndexedBasename sets one indexed entry that contains a comma. It fails on 4.0.x.
  • testMessageSourceCreatedWithSurroundingWhitespaceInBasenameList sets one list entry with whitespace at both ends. It fails if the condition does not trim entries.

On JDK 25, :core:spring-boot-autoconfigure:check passes.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. label Nov 23, 2026
sonic8-8 added a commit to sonic8-8/spring-boot that referenced this pull request Nov 23, 2026
ResourceBundleCondition read spring.messages.basename with
Environment.getProperty and a default of "messages". With list
syntax, such as spring.messages.basename[0]=i18n/messages, that call
returned the default. If no "messages" bundle existed,
MessageSourceAutoConfiguration did not define a MessageSource.

The condition now binds spring.messages.basename as a List<String>
with Binder. MessageSourceProperties.basename has the same type.

See spring-projectsgh-52904
Signed-off-by: Seunghwan Lee <seaung13@gmail.com>
@sonic8-8
sonic8-8 force-pushed the messages-basename-list branch from ab8ecbf to a503b9b Compare November 23, 2026 15:37
ResourceBundleCondition read spring.messages.basename with
Environment.getProperty and a default of "messages". With list
syntax, such as spring.messages.basename[0]=i18n/messages, that call
returned the default. If no "messages" bundle existed,
MessageSourceAutoConfiguration did not define a MessageSource.

The condition now binds spring.messages.basename as a List<String>
with Binder. MessageSourceProperties.basename has the same type.

See spring-projectsgh-52904

Signed-off-by: Seunghwan Lee <seaung13@gmail.com>
@sonic8-8
sonic8-8 force-pushed the messages-basename-list branch from a503b9b to 8cce632 Compare November 23, 2026 15:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants