Skip to content

If the !profile selector is used the other profiles can be ignored in <beans profile="!foo,bar"/> [SPR-11093] #15719

@spring-projects-issues

Description

@spring-projects-issues

Dave Syer opened SPR-11093 and commented

The !profile selector in AbstractEnvironment causes premature termination of loop.

Here's the code:

	@Override
	public boolean acceptsProfiles(String... profiles) {
		Assert.notEmpty(profiles, "Must specify at least one profile");
		for (String profile : profiles) {
			if (profile != null && profile.length() > 0 && profile.charAt(0) == '!') {
				return !isProfileActive(profile.substring(1));
			}
			if (isProfileActive(profile)) {
				return true;
			}
		}
		return false;
	}

So with <beans profile="!foo,bar"/> even if the "bar" profile is active the method returns false when "foo" is also active. Maybe that was intentional, but it doesn't match what I read in the Javadocs (and XSD docs).


Affects: 4.0 RC1

Backported to: 3.2.6

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions