Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the comma in "spring.config.activate.on-profile" value and add test #44866

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ The following activation properties are available:
| Property | Note

| `on-profile`
| A profile expression that must match for the document to be active.
| A profile expression that must match for the document to be active,
or a list of profile expressions of which at least one must match for the document to be active.
Please note comma-separated list such as `foo,bar` is equal to `foo\|bar` instead of `foo&bar`.

| `on-cloud-platform`
| The javadoc:org.springframework.boot.cloud.CloudPlatform[] that must be detected for the document to be active.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -200,6 +200,17 @@ void isActiveAgainstBoundDataWhenCloudPlatformDoesntMatch() {
assertThat(properties.isActive(context)).isFalse();
}

@Test
void isActiveAgainstBoundDataWhenProfilesMatchCommaSeparatedList() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("spring.config.activate.on-profile", "a&b,nonexistent");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
ConfigDataActivationContext context = new ConfigDataActivationContext(NULL_CLOUD_PLATFORM,
createTestProfiles());
assertThat(properties.isActive(context)).isTrue();
}

@Test
void getImportOriginWhenCommaListReturnsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
Expand Down