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
9f241a9e
Commit
9f241a9e
authored
Dec 26, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure app index is used when profiles actrive
parent
fe1336ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
ContextIdApplicationContextInitializer.java
...t/initializer/ContextIdApplicationContextInitializer.java
+3
-3
ContextIdApplicationContextInitializerTests.java
...tializer/ContextIdApplicationContextInitializerTests.java
+2
-2
No files found.
spring-boot/src/main/java/org/springframework/boot/context/initializer/ContextIdApplicationContextInitializer.java
View file @
9f241a9e
...
@@ -91,15 +91,15 @@ public class ContextIdApplicationContextInitializer implements
...
@@ -91,15 +91,15 @@ public class ContextIdApplicationContextInitializer implements
private
String
getApplicationId
(
ConfigurableEnvironment
environment
)
{
private
String
getApplicationId
(
ConfigurableEnvironment
environment
)
{
String
name
=
environment
.
resolvePlaceholders
(
this
.
name
);
String
name
=
environment
.
resolvePlaceholders
(
this
.
name
);
String
index
=
environment
.
resolvePlaceholders
(
INDEX_PATTERN
);
String
index
=
environment
.
resolvePlaceholders
(
INDEX_PATTERN
);
if
(!
"null"
.
equals
(
index
))
{
return
name
+
":"
+
index
;
}
String
profiles
=
StringUtils
.
arrayToCommaDelimitedString
(
environment
String
profiles
=
StringUtils
.
arrayToCommaDelimitedString
(
environment
.
getActiveProfiles
());
.
getActiveProfiles
());
if
(
StringUtils
.
hasText
(
profiles
))
{
if
(
StringUtils
.
hasText
(
profiles
))
{
name
=
name
+
":"
+
profiles
;
name
=
name
+
":"
+
profiles
;
}
}
if
(!
"null"
.
equals
(
index
))
{
name
=
name
+
":"
+
index
;
}
return
name
;
return
name
;
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/ContextIdApplicationContextInitializerTests.java
View file @
9f241a9e
...
@@ -51,9 +51,9 @@ public class ContextIdApplicationContextInitializerTests {
...
@@ -51,9 +51,9 @@ public class ContextIdApplicationContextInitializerTests {
public
void
testNameAndProfiles
()
{
public
void
testNameAndProfiles
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
TestUtils
.
addEnviroment
(
context
,
"spring.application.name:foo"
,
TestUtils
.
addEnviroment
(
context
,
"spring.application.name:foo"
,
"spring.profiles.active: spam,bar"
);
"spring.profiles.active: spam,bar"
,
"spring.application.index:12"
);
this
.
initializer
.
initialize
(
context
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"foo:spam,bar"
,
context
.
getId
());
assertEquals
(
"foo:spam,bar
:12
"
,
context
.
getId
());
}
}
@Test
@Test
...
...
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