mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor connection reset
This commit is contained in:
@@ -146,6 +146,8 @@ public final class ConnectionHolder {
|
||||
JdbcUtils.close(stmt);
|
||||
}
|
||||
statementTrace.clear();
|
||||
|
||||
conn.clearWarnings();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -508,7 +508,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
assert holder != null;
|
||||
|
||||
if (isRemoveAbandoned()) {
|
||||
activeConnections.remove(pooledConnection);
|
||||
ActiveConnectionTraceInfo oldInfo = activeConnections.remove(pooledConnection);
|
||||
if (oldInfo == null) {
|
||||
LOG.warn("remove abandonded failed.");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -527,16 +530,13 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
final boolean isAutoCommit = conn.getAutoCommit();
|
||||
final boolean isReadOnly = conn.isReadOnly();
|
||||
|
||||
// 第二步,检查是否需要回滚
|
||||
// check need to rollback?
|
||||
if ((!isAutoCommit) && (!isReadOnly)) {
|
||||
pooledConnection.rollback();
|
||||
}
|
||||
|
||||
// 第三步,清楚警告信息,重设autoCommit为true
|
||||
conn.clearWarnings();
|
||||
if (!isAutoCommit) {
|
||||
conn.setAutoCommit(true);
|
||||
}
|
||||
|
||||
// reset holder, restore default settings, clear warnings
|
||||
holder.reset();
|
||||
|
||||
if (isTestOnReturn()) {
|
||||
boolean validate = testConnectionInternal(conn);
|
||||
|
||||
@@ -131,7 +131,6 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
listener.connectionClosed(new ConnectionEvent(this));
|
||||
}
|
||||
|
||||
holder.reset();
|
||||
holder.getDataSource().recycle(this);
|
||||
|
||||
this.holder = null;
|
||||
|
||||
Reference in New Issue
Block a user