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
703b7d92
Commit
703b7d92
authored
Mar 07, 2017
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.4.x' into 1.5.x
parents
fedd7b95
67068fc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
EnvironmentMvcEndpoint.java
...ork/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java
+10
-1
EnvironmentMvcEndpointTests.java
...oot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
+10
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java
View file @
703b7d92
...
...
@@ -22,8 +22,10 @@ import org.springframework.context.EnvironmentAware;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.EnumerablePropertySource
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.PropertyResolver
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySources
;
import
org.springframework.core.env.PropertySourcesPropertyResolver
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -93,7 +95,14 @@ public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
@Override
protected
Object
getOptionalValue
(
Environment
source
,
String
name
)
{
Object
result
=
source
.
getProperty
(
name
);
PropertyResolver
resolver
=
source
;
if
(
source
instanceof
ConfigurableEnvironment
)
{
resolver
=
new
PropertySourcesPropertyResolver
(
((
ConfigurableEnvironment
)
source
).
getPropertySources
());
((
PropertySourcesPropertyResolver
)
resolver
)
.
setIgnoreUnresolvableNestedPlaceholders
(
true
);
}
Object
result
=
resolver
.
getProperty
(
name
);
if
(
result
!=
null
)
{
result
=
((
EnvironmentEndpoint
)
getDelegate
()).
sanitize
(
name
,
result
);
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
View file @
703b7d92
...
...
@@ -138,6 +138,16 @@ public class EnvironmentMvcEndpointTests {
.
andExpect
(
content
().
string
(
containsString
(
"\"fool\":\"baz\""
)));
}
@Test
public
void
nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty
()
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"my.foo"
,
"${my.bar}"
);
((
ConfigurableEnvironment
)
this
.
context
.
getEnvironment
()).
getPropertySources
()
.
addFirst
(
new
MapPropertySource
(
"unresolved-placeholder"
,
map
));
this
.
mvc
.
perform
(
get
(
"/env/my.*"
)).
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"\"my.foo\":\"${my.bar}\""
)));
}
@Configuration
@Import
({
JacksonAutoConfiguration
.
class
,
HttpMessageConvertersAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
,
...
...
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