From 4e6fb821b0eaaaa16a50ff343f0c7503cfc50c70 Mon Sep 17 00:00:00 2001 From: xiqiu Date: Wed, 2 Nov 2022 14:00:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-83447=20=20=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86mysql=E8=87=AA=E5=AE=9A=E4=B9=89=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=92=8Cdruid=E7=9B=91=E6=8E=A7=E4=B8=8D=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/third/alibaba/druid/util/MySqlUtils.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java b/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java index c5523d370..fb1576c4c 100644 --- a/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java +++ b/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java @@ -16,6 +16,7 @@ package com.fr.third.alibaba.druid.util; import com.fr.third.alibaba.druid.DbType; +import com.fr.third.alibaba.druid.proxy.jdbc.ConnectionProxy; import com.fr.third.alibaba.druid.sql.SQLUtils; import com.fr.third.alibaba.druid.sql.ast.statement.SQLCreateTableStatement; @@ -403,8 +404,13 @@ public class MySqlUtils { } public static long getLastPacketReceivedTimeMs(Connection conn) throws SQLException { - - ClassLoader cl = conn.getClass().getClassLoader(); + // durid监控若开启,Connection 对象是 ConnectionProxy ,且ConnectionProxy和Connection不是一个同一个类加载器 + ClassLoader cl; + if (conn instanceof ConnectionProxy) { + cl = ((ConnectionProxy) conn).getRawObject().getClass().getClassLoader(); + } else { + cl = conn.getClass().getClassLoader(); + } ConnectionClass cc = classLoaderConnectionClassMap.compute(cl, (k, v) -> { if (v == null || v.class_connectionImpl.getClassLoader() != cl) { return new ConnectionClass(); From d7d38ef08e9aa17f8e98d29aeb79aea1aa724d37 Mon Sep 17 00:00:00 2001 From: xiqiu Date: Wed, 2 Nov 2022 14:04:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-83447=20=20=E6=94=B9=E4=B8=8B?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java b/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java index fb1576c4c..bdaa15baa 100644 --- a/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java +++ b/fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java @@ -404,7 +404,7 @@ public class MySqlUtils { } public static long getLastPacketReceivedTimeMs(Connection conn) throws SQLException { - // durid监控若开启,Connection 对象是 ConnectionProxy ,且ConnectionProxy和Connection不是一个同一个类加载器 + // durid监控若开启,Connection 对象是 ConnectionProxy ,且ConnectionProxy和Connection不一定在同一个类加载器下 ClassLoader cl; if (conn instanceof ConnectionProxy) { cl = ((ConnectionProxy) conn).getRawObject().getClass().getClassLoader();