Browse Source

REPORT-74418 informix等老驱动未实现部分Connection接口导致druid创建线程退出

release/11.0
rinoux 2 years ago
parent
commit
7296844377
  1. 17
      fine-druid/readme.MD
  2. 104
      fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java

17
fine-druid/readme.MD

@ -8,11 +8,12 @@
> 由于需要适配数据源的一些特性和默认配置,对Druid有部分修改,后续更新都要保留下列修改 > 由于需要适配数据源的一些特性和默认配置,对Druid有部分修改,后续更新都要保留下列修改
| 版本 | 日期 | FineReport变动 | | 版本 | 日期 | 任务编号 | FineReport变动 |
|-------|------------|-------------------------------------------------------------------------------------| |-------|------------|----|------------------------------------------------------------------------------------|
| 1.2.9 | 2022-04-27 | DruidAbstractDataSource.testConnectionInternal()判断timeBetweenEvictionRunsMillis > 0 | | 1.2.9 | 2022-04-27 | |DruidAbstractDataSource.testConnectionInternal()判断timeBetweenEvictionRunsMillis > 0 |
| 1.2.9 | 2022-04-27 | MysqlUtils.getLastPacketReceivedTimeMs添加驱动判断 | | 1.2.9 | 2022-04-27 | |MysqlUtils.getLastPacketReceivedTimeMs添加驱动判断 |
| 1.2.9 | 2022-05-05 | MysqlUtils.getLastPacketReceivedTimeMs根据类加载器区分连接实现等,不在使用全局变量 | | 1.2.9 | 2022-05-05 | |MysqlUtils.getLastPacketReceivedTimeMs根据类加载器区分连接实现等,不在使用全局变量 |
| 1.2.9 | 2022-05-05 | com.fr.third.alibaba.druid.util.Utils.loadClass改为优先从线程类加载器加载类 | | 1.2.9 | 2022-05-05 | | com.fr.third.alibaba.druid.util.Utils.loadClass改为优先从线程类加载器加载类 |
| 1.2.9 | 2022-05-05 | 恢复com.fr.third.alibaba.druid.pool.DruidDataSourceFactory对hibernate配置属性的支持 | | 1.2.9 | 2022-05-05 | |恢复com.fr.third.alibaba.druid.pool.DruidDataSourceFactory对hibernate配置属性的支持 |
| 1.2.9 | 2022-05-10 | 恢复DruidDataSource中的创建线程启停机制 | | 1.2.9 | 2022-05-10 | |恢复DruidDataSource中的创建线程启停机制 |
| 1.2.9 | 2022-06-27 | REPORT-74418 |DruidConnectionHolder初始化时捕获AbstractMethodError异常防止获取getHoldability错误导致创建线程退出 |

104
fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java

@ -15,6 +15,16 @@
*/ */
package com.fr.third.alibaba.druid.pool; package com.fr.third.alibaba.druid.pool;
import com.fr.third.alibaba.druid.DbType;
import com.fr.third.alibaba.druid.pool.DruidAbstractDataSource.PhysicalConnectionInfo;
import com.fr.third.alibaba.druid.proxy.jdbc.WrapperProxy;
import com.fr.third.alibaba.druid.support.logging.Log;
import com.fr.third.alibaba.druid.support.logging.LogFactory;
import com.fr.third.alibaba.druid.util.JdbcUtils;
import com.fr.third.alibaba.druid.util.Utils;
import javax.sql.ConnectionEventListener;
import javax.sql.StatementEventListener;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLFeatureNotSupportedException;
@ -26,73 +36,61 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import javax.sql.ConnectionEventListener;
import javax.sql.StatementEventListener;
import com.fr.third.alibaba.druid.DbType;
import com.fr.third.alibaba.druid.pool.DruidAbstractDataSource.PhysicalConnectionInfo;
import com.fr.third.alibaba.druid.proxy.jdbc.WrapperProxy;
import com.fr.third.alibaba.druid.support.logging.Log;
import com.fr.third.alibaba.druid.support.logging.LogFactory;
import com.fr.third.alibaba.druid.util.JdbcConstants;
import com.fr.third.alibaba.druid.util.JdbcUtils;
import com.fr.third.alibaba.druid.util.Utils;
/** /**
* @author wenshao [szujobs@hotmail.com] * @author wenshao [szujobs@hotmail.com]
*/ */
public final class DruidConnectionHolder { public final class DruidConnectionHolder {
private final static Log LOG = LogFactory.getLog(DruidConnectionHolder.class); private final static Log LOG = LogFactory.getLog(DruidConnectionHolder.class);
public static boolean holdabilityUnsupported = false; public static boolean holdabilityUnsupported = false;
protected final DruidAbstractDataSource dataSource; protected final DruidAbstractDataSource dataSource;
protected final long connectionId; protected final long connectionId;
protected final Connection conn; protected final Connection conn;
protected final List<ConnectionEventListener> connectionEventListeners = new CopyOnWriteArrayList<ConnectionEventListener>(); protected final List<ConnectionEventListener> connectionEventListeners = new CopyOnWriteArrayList<ConnectionEventListener>();
protected final List<StatementEventListener> statementEventListeners = new CopyOnWriteArrayList<StatementEventListener>(); protected final List<StatementEventListener> statementEventListeners = new CopyOnWriteArrayList<StatementEventListener>();
protected final long connectTimeMillis; protected final long connectTimeMillis;
protected volatile long lastActiveTimeMillis; protected volatile long lastActiveTimeMillis;
protected volatile long lastExecTimeMillis; protected volatile long lastExecTimeMillis;
protected volatile long lastKeepTimeMillis; protected volatile long lastKeepTimeMillis;
protected volatile long lastValidTimeMillis; protected volatile long lastValidTimeMillis;
protected long useCount = 0; protected long useCount = 0;
private long keepAliveCheckCount = 0; private long keepAliveCheckCount = 0;
private long lastNotEmptyWaitNanos; private long lastNotEmptyWaitNanos;
private final long createNanoSpan; private final long createNanoSpan;
protected PreparedStatementPool statementPool; protected PreparedStatementPool statementPool;
protected final List<Statement> statementTrace = new ArrayList<Statement>(2); protected final List<Statement> statementTrace = new ArrayList<Statement>(2);
protected final boolean defaultReadOnly; protected final boolean defaultReadOnly;
protected final int defaultHoldability; protected final int defaultHoldability;
protected final int defaultTransactionIsolation; protected final int defaultTransactionIsolation;
protected final boolean defaultAutoCommit; protected final boolean defaultAutoCommit;
protected boolean underlyingReadOnly; protected boolean underlyingReadOnly;
protected int underlyingHoldability; protected int underlyingHoldability;
protected int underlyingTransactionIsolation; protected int underlyingTransactionIsolation;
protected boolean underlyingAutoCommit; protected boolean underlyingAutoCommit;
protected volatile boolean discard = false; protected volatile boolean discard = false;
protected volatile boolean active = false; protected volatile boolean active = false;
protected final Map<String, Object> variables; protected final Map<String, Object> variables;
protected final Map<String, Object> globleVariables; protected final Map<String, Object> globleVariables;
final ReentrantLock lock = new ReentrantLock(); final ReentrantLock lock = new ReentrantLock();
protected String initSchema; protected String initSchema;
public DruidConnectionHolder(DruidAbstractDataSource dataSource, PhysicalConnectionInfo pyConnectInfo) public DruidConnectionHolder(DruidAbstractDataSource dataSource, PhysicalConnectionInfo pyConnectInfo)
throws SQLException{ throws SQLException {
this(dataSource, this(dataSource,
pyConnectInfo.getPhysicalConnection(), pyConnectInfo.getPhysicalConnection(),
pyConnectInfo.getConnectNanoSpan(), pyConnectInfo.getConnectNanoSpan(),
pyConnectInfo.getVairiables(), pyConnectInfo.getVairiables(),
pyConnectInfo.getGlobalVairiables()); pyConnectInfo.getGlobalVairiables());
} }
public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan) public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan)
throws SQLException{ throws SQLException {
this(dataSource, conn, connectNanoSpan, null, null); this(dataSource, conn, connectNanoSpan, null, null);
} }
public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan, public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan,
Map<String, Object> variables, Map<String, Object> globleVariables) Map<String, Object> variables, Map<String, Object> globleVariables)
throws SQLException{ throws SQLException {
this.dataSource = dataSource; this.dataSource = dataSource;
this.conn = conn; this.conn = conn;
this.createNanoSpan = connectNanoSpan; this.createNanoSpan = connectNanoSpan;
@ -101,7 +99,7 @@ public final class DruidConnectionHolder {
this.connectTimeMillis = System.currentTimeMillis(); this.connectTimeMillis = System.currentTimeMillis();
this.lastActiveTimeMillis = connectTimeMillis; this.lastActiveTimeMillis = connectTimeMillis;
this.lastExecTimeMillis = connectTimeMillis; this.lastExecTimeMillis = connectTimeMillis;
this.underlyingAutoCommit = conn.getAutoCommit(); this.underlyingAutoCommit = conn.getAutoCommit();
@ -136,6 +134,8 @@ public final class DruidConnectionHolder {
holdabilityUnsupported = true; holdabilityUnsupported = true;
} }
LOG.warn("getHoldability error", e); LOG.warn("getHoldability error", e);
} catch (AbstractMethodError e) {
LOG.warn("getHoldability unsupported", e);
} }
} }
} }
@ -322,7 +322,7 @@ public final class DruidConnectionHolder {
Statement stmt = (Statement) item; Statement stmt = (Statement) item;
JdbcUtils.close(stmt); JdbcUtils.close(stmt);
} }
statementTrace.clear(); statementTrace.clear();
} finally { } finally {
lock.unlock(); lock.unlock();

Loading…
Cancel
Save