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

The @ActiveProfiles annotation no longer overrides those defined in property files #21302

Closed
izeye opened this issue May 4, 2020 · 2 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@izeye
Copy link
Contributor

izeye commented May 4, 2020

@ActiveProfiles replaces profiles from SPRING_PROFILES_ACTIVE environment variable with its value in 2.3.0.M4, but it appends its value to profiles from the environment variable in 2.3.0.RC1.

I'm not sure if this is an intentional change or more appropriate, but I'm sharing this as I didn't see any explicit mention from its release notes or issue assigned to its milestone.

This can be produced with ActiveProfilesTests from this sample.

If the following environment variable is defined, the test will pass with 2.3.0.M4, but it will fail with 2.3.0.RC1:

export SPRING_PROFILES_ACTIVE=local
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 4, 2020
@mbhave
Copy link
Contributor

mbhave commented May 4, 2020

#19788 was fixed but #21006 could have introduced something.

@mbhave
Copy link
Contributor

mbhave commented May 4, 2020

SpringApplication makes a call to environment.getActiveProfiles() which has a side-effect of setting active profiles if they haven't been set before. At this point, Spring Framework, sets the active profiles from the spring.profiles.active. Since the SpringBootContextLoader adds them as indexed properties now, those do not override SPRING_PROFILES_ACTIVE at this point.

I think the change made for #21006 also means that if there's a system property such as spring.profiles.active[0] and an environment variable SPRING_PROFILES_ACTIVE, the system property won't override the environment variable but instead both will be added as active profiles.

@mbhave mbhave added the for: team-attention An issue we'd like other members of the team to review label May 5, 2020
@philwebb philwebb added type: regression A regression from a previous release and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels May 6, 2020
@philwebb philwebb added this to the 2.3.0 milestone May 6, 2020
@philwebb philwebb self-assigned this May 6, 2020
@philwebb philwebb changed the title Behavioral change in @ActiveProfiles The @ActiveProfiles annotation no longer overrides those defined in property files May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants