From 7296844377b9a2861d20d4e890b539ce90225f05 Mon Sep 17 00:00:00 2001 From: rinoux Date: Mon, 27 Jun 2022 10:42:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-74418=20informix=E7=AD=89=E8=80=81?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E6=9C=AA=E5=AE=9E=E7=8E=B0=E9=83=A8=E5=88=86?= =?UTF-8?q?Connection=E6=8E=A5=E5=8F=A3=E5=AF=BC=E8=87=B4druid=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=BA=BF=E7=A8=8B=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-druid/readme.MD | 17 +-- .../druid/pool/DruidConnectionHolder.java | 104 +++++++++--------- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/fine-druid/readme.MD b/fine-druid/readme.MD index 275182ba3..728b4f75d 100644 --- a/fine-druid/readme.MD +++ b/fine-druid/readme.MD @@ -8,11 +8,12 @@ > 由于需要适配数据源的一些特性和默认配置,对Druid有部分修改,后续更新都要保留下列修改 -| 版本 | 日期 | FineReport变动 | -|-------|------------|-------------------------------------------------------------------------------------| -| 1.2.9 | 2022-04-27 | DruidAbstractDataSource.testConnectionInternal()判断timeBetweenEvictionRunsMillis > 0 | -| 1.2.9 | 2022-04-27 | 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.pool.DruidDataSourceFactory对hibernate配置属性的支持 | -| 1.2.9 | 2022-05-10 | 恢复DruidDataSource中的创建线程启停机制 | +| 版本 | 日期 | 任务编号 | FineReport变动 | +|-------|------------|----|------------------------------------------------------------------------------------| +| 1.2.9 | 2022-04-27 | |DruidAbstractDataSource.testConnectionInternal()判断timeBetweenEvictionRunsMillis > 0 | +| 1.2.9 | 2022-04-27 | |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.pool.DruidDataSourceFactory对hibernate配置属性的支持 | +| 1.2.9 | 2022-05-10 | |恢复DruidDataSource中的创建线程启停机制 | +| 1.2.9 | 2022-06-27 | REPORT-74418 |DruidConnectionHolder初始化时捕获AbstractMethodError异常防止获取getHoldability错误导致创建线程退出 | \ No newline at end of file diff --git a/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java b/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java index 8ac60c646..94d249c23 100644 --- a/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java +++ b/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java @@ -15,6 +15,16 @@ */ 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.SQLException; import java.sql.SQLFeatureNotSupportedException; @@ -26,73 +36,61 @@ import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; 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] */ public final class DruidConnectionHolder { - private final static Log LOG = LogFactory.getLog(DruidConnectionHolder.class); - public static boolean holdabilityUnsupported = false; + private final static Log LOG = LogFactory.getLog(DruidConnectionHolder.class); + public static boolean holdabilityUnsupported = false; - protected final DruidAbstractDataSource dataSource; - protected final long connectionId; - protected final Connection conn; + protected final DruidAbstractDataSource dataSource; + protected final long connectionId; + protected final Connection conn; protected final List connectionEventListeners = new CopyOnWriteArrayList(); - protected final List statementEventListeners = new CopyOnWriteArrayList(); - protected final long connectTimeMillis; - protected volatile long lastActiveTimeMillis; - protected volatile long lastExecTimeMillis; - protected volatile long lastKeepTimeMillis; - protected volatile long lastValidTimeMillis; - protected long useCount = 0; - private long keepAliveCheckCount = 0; - private long lastNotEmptyWaitNanos; - private final long createNanoSpan; - protected PreparedStatementPool statementPool; - protected final List statementTrace = new ArrayList(2); - protected final boolean defaultReadOnly; - protected final int defaultHoldability; - protected final int defaultTransactionIsolation; - protected final boolean defaultAutoCommit; - protected boolean underlyingReadOnly; - protected int underlyingHoldability; - protected int underlyingTransactionIsolation; - protected boolean underlyingAutoCommit; - protected volatile boolean discard = false; - protected volatile boolean active = false; - protected final Map variables; - protected final Map globleVariables; - final ReentrantLock lock = new ReentrantLock(); - protected String initSchema; + protected final List statementEventListeners = new CopyOnWriteArrayList(); + protected final long connectTimeMillis; + protected volatile long lastActiveTimeMillis; + protected volatile long lastExecTimeMillis; + protected volatile long lastKeepTimeMillis; + protected volatile long lastValidTimeMillis; + protected long useCount = 0; + private long keepAliveCheckCount = 0; + private long lastNotEmptyWaitNanos; + private final long createNanoSpan; + protected PreparedStatementPool statementPool; + protected final List statementTrace = new ArrayList(2); + protected final boolean defaultReadOnly; + protected final int defaultHoldability; + protected final int defaultTransactionIsolation; + protected final boolean defaultAutoCommit; + protected boolean underlyingReadOnly; + protected int underlyingHoldability; + protected int underlyingTransactionIsolation; + protected boolean underlyingAutoCommit; + protected volatile boolean discard = false; + protected volatile boolean active = false; + protected final Map variables; + protected final Map globleVariables; + final ReentrantLock lock = new ReentrantLock(); + protected String initSchema; public DruidConnectionHolder(DruidAbstractDataSource dataSource, PhysicalConnectionInfo pyConnectInfo) - throws SQLException{ + throws SQLException { this(dataSource, - pyConnectInfo.getPhysicalConnection(), - pyConnectInfo.getConnectNanoSpan(), - pyConnectInfo.getVairiables(), - pyConnectInfo.getGlobalVairiables()); + pyConnectInfo.getPhysicalConnection(), + pyConnectInfo.getConnectNanoSpan(), + pyConnectInfo.getVairiables(), + pyConnectInfo.getGlobalVairiables()); } public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan) - throws SQLException{ + throws SQLException { this(dataSource, conn, connectNanoSpan, null, null); } public DruidConnectionHolder(DruidAbstractDataSource dataSource, Connection conn, long connectNanoSpan, Map variables, Map globleVariables) - throws SQLException{ + throws SQLException { this.dataSource = dataSource; this.conn = conn; this.createNanoSpan = connectNanoSpan; @@ -101,7 +99,7 @@ public final class DruidConnectionHolder { this.connectTimeMillis = System.currentTimeMillis(); this.lastActiveTimeMillis = connectTimeMillis; - this.lastExecTimeMillis = connectTimeMillis; + this.lastExecTimeMillis = connectTimeMillis; this.underlyingAutoCommit = conn.getAutoCommit(); @@ -136,6 +134,8 @@ public final class DruidConnectionHolder { holdabilityUnsupported = true; } 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; JdbcUtils.close(stmt); } - + statementTrace.clear(); } finally { lock.unlock(); From 8149d3a29280ae52ce16161b4afe0a7fa8a12a19 Mon Sep 17 00:00:00 2001 From: rinoux Date: Mon, 27 Jun 2022 11:08:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-74418=20informix=E7=AD=89=E8=80=81?= =?UTF-8?q?=E9=A9=B1=E5=8A=A8=E6=9C=AA=E5=AE=9E=E7=8E=B0=E9=83=A8=E5=88=86?= =?UTF-8?q?Connection=E6=8E=A5=E5=8F=A3=E5=AF=BC=E8=87=B4druid=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E7=BA=BF=E7=A8=8B=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/alibaba/druid/pool/DruidConnectionHolder.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java b/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java index 94d249c23..5f8c0485e 100644 --- a/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java +++ b/fine-druid/src/main/java/com/fr/third/alibaba/druid/pool/DruidConnectionHolder.java @@ -122,10 +122,7 @@ public final class DruidConnectionHolder { if (initUnderlyHoldability) { try { this.underlyingHoldability = conn.getHoldability(); - } catch (UnsupportedOperationException e) { - holdabilityUnsupported = true; - LOG.warn("getHoldability unsupported", e); - } catch (SQLFeatureNotSupportedException e) { + } catch (UnsupportedOperationException | AbstractMethodError | SQLFeatureNotSupportedException e) { holdabilityUnsupported = true; LOG.warn("getHoldability unsupported", e); } catch (SQLException e) { @@ -134,8 +131,8 @@ public final class DruidConnectionHolder { holdabilityUnsupported = true; } LOG.warn("getHoldability error", e); - } catch (AbstractMethodError e) { - LOG.warn("getHoldability unsupported", e); + } catch (Throwable e) { + LOG.warn("getHoldability error", e); } } }