Skip to content

Commit a28cc13

Browse files
committed
Merge pull request #52872 from ShakilUrRehman21
Closes gh-52872 * pr/52872: Preserve spaces in basenames when matching ResourceBundleCondition
2 parents bc329b5 + 2da2829 commit a28cc13

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
114114

115115
private ConditionOutcome getMatchOutcomeForBasename(@Nullable ClassLoader classLoader, String basename) {
116116
ConditionMessage.Builder message = ConditionMessage.forCondition("ResourceBundle");
117-
for (String name : StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(basename))) {
117+
for (String name : StringUtils.tokenizeToStringArray(basename, ",")) {
118118
for (Resource resource : getResources(classLoader, name)) {
119119
if (resource.exists()) {
120120
return ConditionOutcome.match(message.found("bundle").items(resource));

‎core/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ void testMultipleMessageSourceCreated() {
133133
});
134134
}
135135

136+
@Test
137+
@WithResource(name = "test/my messages.properties", content = "foo=bar")
138+
void testMultipleMessageSourceCreatedWithSpacesInBasename() {
139+
this.contextRunner.withPropertyValues("spring.messages.basename=test/my messages, test/messages2")
140+
.run((context) -> {
141+
assertThat(context).hasSingleBean(MessageSource.class);
142+
assertThat(context.getMessage("foo", null, "Foo message", Locale.UK)).isEqualTo("bar");
143+
});
144+
}
145+
136146
@Test
137147
@WithTestMessagesPropertiesResource
138148
@Disabled("Expected to fail per gh-1075")

0 commit comments

Comments
 (0)