Skip to content

was returning found anytime negated profile was not found, even if th… #5747

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

Closed
wants to merge 2 commits into from
Closed
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 @@ -68,10 +68,10 @@ public MatchStatus matches(Properties properties) {
if (StringUtils.hasLength(negative)) {
properties = new Properties(properties);
properties.setProperty(SPRING_PROFILES, negative);
switch (activeProfilesMatcher.matches(properties)) {
case FOUND:
if (activeProfilesMatcher.matches(properties) == MatchStatus.FOUND) {
return MatchStatus.NOT_FOUND;
case NOT_FOUND:
}
if (StringUtils.isEmpty(positive)) {
return MatchStatus.FOUND;
}
properties.setProperty(SPRING_PROFILES, positive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ public void testInverseMatchMulti() throws IOException {
@Test
public void negatedAndNonNegated() throws IOException {
DocumentMatcher matcher = new SpringProfileDocumentMatcher("foo", "bar", "blah");
Properties properties = getProperties("spring.profiles: !baz,blah");
assertThat(matcher.matches(properties)).isEqualTo(MatchStatus.FOUND);
Properties expectFound = getProperties("spring.profiles: !baz,blah");
assertThat(matcher.matches(expectFound)).isEqualTo(MatchStatus.FOUND);
Properties expectNotFound = getProperties("spring.profiles: !baz,another");
assertThat(matcher.matches(expectNotFound)).isEqualTo(MatchStatus.NOT_FOUND);
}

@Test
Expand Down