Polish DatabaseStartupValidator.afterPropertiesSet()
This commit is contained in:
parent
e458777925
commit
964467d269
|
|
@ -104,8 +104,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
DataSource dataSource = this.dataSource;
|
if (this.dataSource == null) {
|
||||||
if (dataSource == null) {
|
|
||||||
throw new IllegalArgumentException("Property 'dataSource' is required");
|
throw new IllegalArgumentException("Property 'dataSource' is required");
|
||||||
}
|
}
|
||||||
if (this.validationQuery == null) {
|
if (this.validationQuery == null) {
|
||||||
|
|
@ -122,10 +121,10 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||||
Connection con = null;
|
Connection con = null;
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
con = dataSource.getConnection();
|
con = this.dataSource.getConnection();
|
||||||
if (con == null) {
|
if (con == null) {
|
||||||
throw new CannotGetJdbcConnectionException("Failed to execute validation query: " +
|
throw new CannotGetJdbcConnectionException("Failed to execute validation query: " +
|
||||||
"DataSource returned null from getConnection(): " + dataSource);
|
"DataSource returned null from getConnection(): " + this.dataSource);
|
||||||
}
|
}
|
||||||
stmt = con.createStatement();
|
stmt = con.createStatement();
|
||||||
stmt.execute(this.validationQuery);
|
stmt.execute(this.validationQuery);
|
||||||
|
|
@ -150,7 +149,7 @@ public class DatabaseStartupValidator implements InitializingBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validated) {
|
if (!validated) {
|
||||||
Thread.sleep(TimeUnit.SECONDS.toMillis(this.interval));
|
TimeUnit.SECONDS.sleep(this.interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue