Skip to content

MessageSourceAutoConfiguration backs off when spring.messages.basename is configured using list syntax - #52904

Merged
snicoll merged 2 commits into
spring-projects:4.0.xfrom
sonic8-8:messages-basename-list
Nov 26, 2026
Merged

snicoll merged 2 commits into
spring-projects:4.0.xfrom
sonic8-8:messages-basename-list

Conversation

@sonic8-8

Copy link
Copy Markdown
Contributor

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 <[email protected]>
@sonic8-8
sonic8-8 force-pushed the messages-basename-list branch from ab8ecbf to a503b9b Compare November 23, 2026 15:37
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 <[email protected]>
@sonic8-8
sonic8-8 force-pushed the messages-basename-list branch from a503b9b to 8cce632 Compare November 23, 2026 15:42
@snicoll snicoll changed the title Accept list syntax for spring.messages.basename MessageSourceAutoConfiguration backs off when spring.messages.basename is configured using list syntax Nov 26, 2026
@snicoll snicoll self-assigned this Nov 26, 2026
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue that has not yet been triaged. Contributions will not be accepted. labels Nov 26, 2026
@snicoll snicoll added this to the 4.0.11 milestone Nov 26, 2026
sonic8-8 and others added 2 commits November 26, 2026 14:10
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 <[email protected]>
@snicoll
snicoll force-pushed the messages-basename-list branch from 8cce632 to d166563 Compare November 26, 2026 13:11
@snicoll
snicoll merged commit cc44b73 into spring-projects:4.0.x Nov 26, 2026
1 check failed
@snicoll

snicoll commented Nov 26, 2026

Copy link
Copy Markdown
Member

@sonic8-8 thanks but we didn't need to change the condition as you did. I've restored to limit to the binding fix.

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

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants