Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f83cacdc
Commit
f83cacdc
authored
Apr 25, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5747 from mbenson/notprofilesyamlbugfix
* pr/5747: Fix SpringProfileDocumentMatcher negation bug
parents
56146f0e
15d6662c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
SpringProfileDocumentMatcher.java
...ringframework/boot/yaml/SpringProfileDocumentMatcher.java
+3
-3
SpringProfileDocumentMatcherTests.java
...ramework/boot/yaml/SpringProfileDocumentMatcherTests.java
+8
-1
No files found.
spring-boot/src/main/java/org/springframework/boot/yaml/SpringProfileDocumentMatcher.java
View file @
f83cacdc
...
...
@@ -68,10 +68,10 @@ public class SpringProfileDocumentMatcher implements DocumentMatcher {
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
);
...
...
spring-boot/src/test/java/org/springframework/boot/yaml/SpringProfileDocumentMatcherTests.java
View file @
f83cacdc
...
...
@@ -85,12 +85,19 @@ public class SpringProfileDocumentMatcherTests {
}
@Test
public
void
negated
AndNonNegated
()
throws
IO
Exception
{
public
void
negated
WithMatch
()
throws
Exception
{
DocumentMatcher
matcher
=
new
SpringProfileDocumentMatcher
(
"foo"
,
"bar"
,
"blah"
);
Properties
properties
=
getProperties
(
"spring.profiles: !baz,blah"
);
assertThat
(
matcher
.
matches
(
properties
)).
isEqualTo
(
MatchStatus
.
FOUND
);
}
@Test
public
void
negatedWithNoMatch
()
throws
IOException
{
DocumentMatcher
matcher
=
new
SpringProfileDocumentMatcher
(
"foo"
,
"bar"
,
"blah"
);
Properties
properties
=
getProperties
(
"spring.profiles: !baz,another"
);
assertThat
(
matcher
.
matches
(
properties
)).
isEqualTo
(
MatchStatus
.
NOT_FOUND
);
}
@Test
public
void
negatedTrumpsMatching
()
throws
IOException
{
DocumentMatcher
matcher
=
new
SpringProfileDocumentMatcher
(
"foo"
,
"baz"
,
"blah"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment