Hi, this is a first-timers-only
issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
If you have contributed before, consider leaving this one for someone new, and looking through our general ideal-for-contribution
issues. Thanks!
Problem
Spring Boot logs the profiles that are active when the application starts. Profiles are usually activated by parsing a comma-separated list. For example an application can be started with --spring.profiles.active=p1,p2
and the profiles p1
and p2
are activated. It's also possible to have tests that activate profiles using the @ActiveProfiles
annotation. When using this annotation, it's easy to type @ActiveProfiles("p1,p2")
rather than @ActiveProfiles("p1","p2")
. This results in a single profile named "p1,p2", rather than the expected "p1", "p2" profiles.
This issue was originally raised in #29739
Solution
In order to make this mistake easier to find we want to change the log output from:
The following profiles are active: p1,p2
to
The following 1 profile is active: "p1,p2"
or
The following 2 profiles are active: "p1,p2", "p3"
This will involve modifying the SpringApplication.logStartupProfileInfo
method to create a better message.
The log*
tests in SpringApplicationTests
will need to change and an additional test should be added to check a profile that contains comma:
@Test
void logsMultipleActiveProfilesWithComma(CapturedOutput output) {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.setAdditionalProfiles("p1,p2", "p3");
application.run();
assertThat(output).contains("The following 2 profiles are active: \"p1,p2\",\"p3\"");
}
Steps to Fix
- [ ] Claim this issue with a comment below and ask any clarifying questions you need
- [ ] Set up a repository locally following the Contributing Guidelines
- [ ] Try to fix the issue following the steps above
- [ ] Commit your changes and start a pull request.
Comment From: vikeychen
hello, I would like to claim this issue.
Comment From: snicoll
@vikeychen thank you very much for the offer. As you've been already contributing to Spring Framework this week, I think it's best to let someone who hasn't contributed yet to take this one.
Comment From: vikeychen
@snicoll 😄 you are totally right...
Comment From: gcoppex
@snicoll: thanks for the follow up. I have then quickly opened a pull request (#29896) containing this easy fix.
Comment From: wilkinsona
Thanks, @gcoppex. Closing in favor of #29896.