resolve potential test hang if jdbc persistence adapter stop results in an exception, it should handle and log any exceptions

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@796681 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-07-22 11:58:14 +00:00
parent 7f8eb612cd
commit fb42a11835
2 changed files with 17 additions and 7 deletions

View File

@ -115,13 +115,22 @@ public class DefaultDatabaseLocker implements DatabaseLocker {
public void stop() throws Exception {
stopping = true;
try {
if (connection != null && !connection.isClosed()) {
try {
connection.rollback();
} catch (SQLException sqle) {
LOG.warn("Exception while rollbacking the connection on shutdown", sqle);
}
} finally {
try {
connection.close();
} catch (SQLException ignored) {
LOG.debug("Exception while closing connection on shutdown", ignored);
}
}
}
} catch (SQLException sqle) {
LOG.warn("Exception while checking close status of connection on shutdown", sqle);
}
}

View File

@ -14,6 +14,7 @@ public class DbRestartJDBCQueueMasterSlaveTest extends JDBCQueueMasterSlaveTest
protected void messageSent() throws Exception {
if (++inflightMessageCount == failureCount) {
LOG.info("STOPPING DB!@!!!!");
final EmbeddedDataSource ds = getExistingDataSource();
ds.setShutdownDatabase("shutdown");
LOG.info("DB STOPPED!@!!!!");