Skip to content

Commit ba0ffb4

Browse files
committed
Clarify the comma in "spring.config.activate.on-profile" value and add test
See spring-cloud/spring-cloud-commons#1416 (comment) Signed-off-by: Yanming Zhou <[email protected]>
1 parent 859d074 commit ba0ffb4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/properties-and-configuration.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ In the preceding example, the default port is 9000.
291291
However, if the Spring profile called '`development`' is active, then the port is 9001.
292292
If '`production`' is active, then the port is 0.
293293

294+
NOTE: The comma in profile value is equivalent to `|`, `profile1,profile2` is equivalent to `profile1|profile2` not `profile1&profile2`.
295+
294296
NOTE: The documents are merged in the order in which they are encountered.
295297
Later values override earlier values.
296298

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataPropertiesTests.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -200,6 +200,17 @@ void isActiveAgainstBoundDataWhenCloudPlatformDoesntMatch() {
200200
assertThat(properties.isActive(context)).isFalse();
201201
}
202202

203+
@Test
204+
void isActiveAgainstBoundDataWhenProfilesMatchCommaSeparatedList() {
205+
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
206+
source.put("spring.config.activate.on-profile", "a&b,nonexistent");
207+
Binder binder = new Binder(source);
208+
ConfigDataProperties properties = ConfigDataProperties.get(binder);
209+
ConfigDataActivationContext context = new ConfigDataActivationContext(NULL_CLOUD_PLATFORM,
210+
createTestProfiles());
211+
assertThat(properties.isActive(context)).isTrue();
212+
}
213+
203214
@Test
204215
void getImportOriginWhenCommaListReturnsOrigin() {
205216
MapConfigurationPropertySource source = new MapConfigurationPropertySource();

0 commit comments

Comments
 (0)