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
2ca20248
Commit
2ca20248
authored
Mar 05, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20367 from izeye
* pr/20367: Polish DataSourceHealthIndicator Closes gh-20367
parents
de062b4f
bd08b4d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
16 deletions
+8
-16
DataSourceHealthIndicator.java
...ramework/boot/actuate/jdbc/DataSourceHealthIndicator.java
+8
-16
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java
View file @
2ca20248
...
@@ -105,24 +105,16 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
...
@@ -105,24 +105,16 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
builder
.
up
().
withDetail
(
"database"
,
getProduct
());
builder
.
up
().
withDetail
(
"database"
,
getProduct
());
String
validationQuery
=
this
.
query
;
String
validationQuery
=
this
.
query
;
if
(
StringUtils
.
hasText
(
validationQuery
))
{
if
(
StringUtils
.
hasText
(
validationQuery
))
{
try
{
builder
.
withDetail
(
"validationQuery"
,
validationQuery
);
// Avoid calling getObject as it breaks MySQL on Java 7
// Avoid calling getObject as it breaks MySQL on Java 7 and later
List
<
Object
>
results
=
this
.
jdbcTemplate
.
query
(
validationQuery
,
new
SingleColumnRowMapper
());
List
<
Object
>
results
=
this
.
jdbcTemplate
.
query
(
validationQuery
,
new
SingleColumnRowMapper
());
Object
result
=
DataAccessUtils
.
requiredSingleResult
(
results
);
Object
result
=
DataAccessUtils
.
requiredSingleResult
(
results
);
builder
.
withDetail
(
"result"
,
result
);
builder
.
withDetail
(
"result"
,
result
);
}
finally
{
builder
.
withDetail
(
"validationQuery"
,
validationQuery
);
}
}
}
else
{
else
{
try
{
builder
.
withDetail
(
"validationQuery"
,
"isValid()"
);
boolean
valid
=
isConnectionValid
();
boolean
valid
=
isConnectionValid
();
builder
.
status
((
valid
)
?
Status
.
UP
:
Status
.
DOWN
);
builder
.
status
((
valid
)
?
Status
.
UP
:
Status
.
DOWN
);
}
finally
{
builder
.
withDetail
(
"validationQuery"
,
"isValid()"
);
}
}
}
}
}
...
...
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