From c6a184474c99f8ce91604b0164ff8b5b003ed9f0 Mon Sep 17 00:00:00 2001 From: luoyuan <51843122+lyyprean@users.noreply.github.com> Date: Thu, 5 Dec 2019 14:51:21 +0800 Subject: [PATCH] Remove redundant hasText check as query always has text See gh-19290 --- .../boot/actuate/jdbc/DataSourceHealthIndicator.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java index fbb34afd6c2..f0667683ab2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java @@ -107,12 +107,10 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement String product = getProduct(); builder.up().withDetail("database", product); String validationQuery = getValidationQuery(product); - if (StringUtils.hasText(validationQuery)) { - // Avoid calling getObject as it breaks MySQL on Java 7 - List results = this.jdbcTemplate.query(validationQuery, new SingleColumnRowMapper()); - Object result = DataAccessUtils.requiredSingleResult(results); - builder.withDetail("hello", result); - } + // Avoid calling getObject as it breaks MySQL on Java 7 + List results = this.jdbcTemplate.query(validationQuery, new SingleColumnRowMapper()); + Object result = DataAccessUtils.requiredSingleResult(results); + builder.withDetail("hello", result); } private String getProduct() {