Merge pull request #19290 from lyyprean

* gh-19290:
  Remove redundant hasText check as query always has text

Closes gh-19290
This commit is contained in:
Andy Wilkinson 2019-12-05 11:52:47 +00:00
commit c6d4ff6ed5
1 changed files with 4 additions and 6 deletions

View File

@ -107,13 +107,11 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
String product = getProduct(); String product = getProduct();
builder.up().withDetail("database", product); builder.up().withDetail("database", product);
String validationQuery = getValidationQuery(product); String validationQuery = getValidationQuery(product);
if (StringUtils.hasText(validationQuery)) {
// Avoid calling getObject as it breaks MySQL on Java 7 // Avoid calling getObject as it breaks MySQL on Java 7
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("hello", result); builder.withDetail("hello", result);
} }
}
private String getProduct() { private String getProduct() {
return this.jdbcTemplate.execute((ConnectionCallback<String>) this::getProduct); return this.jdbcTemplate.execute((ConnectionCallback<String>) this::getProduct);