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
47d85bb4
Commit
47d85bb4
authored
Apr 11, 2019
by
dreis2211
Committed by
Stephane Nicoll
May 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Duration support in /configprops endpoint
See gh-16539
parent
bc90d48f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
ConfigurationPropertiesReportEndpoint.java
...ext/properties/ConfigurationPropertiesReportEndpoint.java
+3
-0
ConfigurationPropertiesReportEndpointTests.java
...roperties/ConfigurationPropertiesReportEndpointTests.java
+21
-0
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java
View file @
47d85bb4
...
...
@@ -41,6 +41,7 @@ import com.fasterxml.jackson.databind.ser.PropertyWriter;
import
com.fasterxml.jackson.databind.ser.SerializerFactory
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -172,10 +173,12 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
*/
protected
void
configureObjectMapper
(
ObjectMapper
mapper
)
{
mapper
.
configure
(
SerializationFeature
.
FAIL_ON_EMPTY_BEANS
,
false
);
mapper
.
configure
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
,
false
);
mapper
.
configure
(
MapperFeature
.
USE_STD_BEAN_NAMING
,
true
);
mapper
.
setSerializationInclusion
(
Include
.
NON_NULL
);
applyConfigurationPropertiesFilter
(
mapper
);
applySerializationModifier
(
mapper
);
mapper
.
registerModule
(
new
JavaTimeModule
());
}
private
ObjectMapper
getObjectMapper
()
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java
View file @
47d85bb4
...
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
context
.
properties
;
import
java.time.Duration
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
...
...
@@ -157,6 +158,16 @@ public class ConfigurationPropertiesReportEndpointTests {
});
}
@Test
public
void
duration
()
{
load
((
context
,
properties
)
->
{
Map
<
String
,
Object
>
nestedProperties
=
properties
.
getBeans
()
.
get
(
"testProperties"
).
getProperties
();
assertThat
(
nestedProperties
.
get
(
"duration"
))
.
isEqualTo
(
Duration
.
ofSeconds
(
10
).
toString
());
});
}
@Test
public
void
singleLetterProperty
()
{
load
((
context
,
properties
)
->
{
...
...
@@ -276,6 +287,8 @@ public class ConfigurationPropertiesReportEndpointTests {
private
String
nullValue
=
null
;
private
Duration
duration
=
Duration
.
ofSeconds
(
10
);
public
TestProperties
()
{
this
.
secrets
.
put
(
"mine"
,
"myPrivateThing"
);
this
.
secrets
.
put
(
"yours"
,
"yourPrivateThing"
);
...
...
@@ -379,6 +392,14 @@ public class ConfigurationPropertiesReportEndpointTests {
this
.
nullValue
=
nullValue
;
}
public
Duration
getDuration
()
{
return
this
.
duration
;
}
public
void
setDuration
(
Duration
duration
)
{
this
.
duration
=
duration
;
}
public
static
class
Hidden
{
private
String
mine
=
"mySecret"
;
...
...
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