async close support

This commit is contained in:
wenshao
2014-08-29 06:14:26 +08:00
parent 6caf8fe300
commit 8551bf6580
5 changed files with 293 additions and 3 deletions
@@ -1169,6 +1169,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
if (requireDiscard) {
this.discardConnection(holder.getConnection());
holder.setDiscard(true);
}
LOG.error("discard connection", sqlEx);
@@ -1225,7 +1226,18 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
}
// reset holder, restore default settings, clear warnings
holder.reset();
boolean isSameThread = pooledConnection.getOwnerThread() == Thread.currentThread();
if (!isSameThread) {
synchronized (pooledConnection) {
holder.reset();
}
} else {
holder.reset();
}
if (holder.isDiscard()) {
return;
}
if (testOnReturn) {
boolean validate = testConnectionInternal(physicalConnection);