Polish DataSourceHealthIndicator

See gh-20367
pull/20407/head
Johnny Lim 5 years ago committed by Stephane Nicoll
parent de062b4f52
commit bd08b4d91c

@ -105,24 +105,16 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator implement
builder.up().withDetail("database", getProduct());
String validationQuery = this.query;
if (StringUtils.hasText(validationQuery)) {
try {
// Avoid calling getObject as it breaks MySQL on Java 7
List<Object> results = this.jdbcTemplate.query(validationQuery, new SingleColumnRowMapper());
Object result = DataAccessUtils.requiredSingleResult(results);
builder.withDetail("result", result);
}
finally {
builder.withDetail("validationQuery", validationQuery);
}
builder.withDetail("validationQuery", validationQuery);
// Avoid calling getObject as it breaks MySQL on Java 7 and later
List<Object> results = this.jdbcTemplate.query(validationQuery, new SingleColumnRowMapper());
Object result = DataAccessUtils.requiredSingleResult(results);
builder.withDetail("result", result);
}
else {
try {
boolean valid = isConnectionValid();
builder.status((valid) ? Status.UP : Status.DOWN);
}
finally {
builder.withDetail("validationQuery", "isValid()");
}
builder.withDetail("validationQuery", "isValid()");
boolean valid = isConnectionValid();
builder.status((valid) ? Status.UP : Status.DOWN);
}
}

Loading…
Cancel
Save