Skip to content

The active profiles log message is ambiguous when a profile's name contains a comma #29891

@philwebb

Description

@philwebb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions