bug fixed for removeAbandonded concurrent problem

This commit is contained in:
wenshao
2012-10-23 08:21:19 +08:00
parent 466067f285
commit f1a0cb5191
3 changed files with 139 additions and 6 deletions
@@ -60,7 +60,7 @@ public class DruidPooledConnection implements javax.sql.PooledConnection, Connec
protected volatile DruidConnectionHolder holder;
protected TransactionInfo transactionInfo;
private final boolean dupCloseLogEnable;
private boolean traceEnable = false;
private volatile boolean traceEnable = false;
private boolean disable = false;
private boolean closed = false;
private final Thread ownerThread;
@@ -212,6 +212,40 @@ public class DruidPooledConnection implements javax.sql.PooledConnection, Connec
return;
}
if (holder.getDataSource().isRemoveAbandoned()) {
syncClose();
return;
}
for (ConnectionEventListener listener : holder.getConnectionEventListeners()) {
listener.connectionClosed(new ConnectionEvent(this));
}
DruidAbstractDataSource dataSource = holder.getDataSource();
List<Filter> filters = dataSource.getProxyFilters();
if (filters.size() > 0) {
FilterChainImpl filterChain = new FilterChainImpl(dataSource);
filterChain.dataSource_recycle(this);
} else {
recycle();
}
this.disable = true;
}
public synchronized void syncClose() throws SQLException {
if (this.disable) {
return;
}
DruidConnectionHolder holder = this.holder;
if (holder == null) {
if (dupCloseLogEnable) {
LOG.error("dup close");
}
return;
}
for (ConnectionEventListener listener : holder.getConnectionEventListeners()) {
listener.connectionClosed(new ConnectionEvent(this));
}