Skip to content

Commit dea82ba

Browse files
authored
Merge branch '2.x' into 20250926
2 parents 4d4c9da + 0605fa8 commit dea82ba

File tree

61 files changed

+1848
-759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1848
-759
lines changed

.github/workflows/test-druid.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
druid: [
45+
1.2.25,
46+
# 1.2.24, #The source code depends on guava, resulting in a class not found, see the commit https://github.com/alibaba/druid/commit/f060c2701587948380bd0d07d5baf4f774c06e8a#diff-5200f514252efbc0c4b2dc51ebad5d840b4b3065b9556eb4368bd3476d4c220eR25
47+
1.2.23,
48+
1.2.22,
49+
1.2.21,
4550
1.2.20,
4651
1.2.19,
4752
#1.2.18, # Unit test triggered a bug in Druid, see the commit https://github.com/alibaba/druid/commit/6c493f852852fb287ed5fd31ee16c27ead0ea5cf

changes/en-us/2.x.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ Add changes here for all PR submitted to the 2.x branch.
2626
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils add support for DM Database
2727
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] Introduce Cleanup API for TableMetaRefreshHolder Instance
2828
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] add support for Jackson serialization and deserialization of PostgreSQL array types
29+
- [[#7664](https://github.com/apache/incubator-seata/pull/7664)] support shentongdatabase XA mode
2930

3031
### bugfix:
3132

33+
- [[#6476](https://github.com/apache/seata/issues/6476)] Fix SerialArray equals() method for multi-dimensional array comparison in Phase 2 rollback
3234
- [[#7482](https://github.com/apache/incubator-seata/pull/7482)] Github Action workflow does not run the corresponding Kotlin test
3335
- [[#7538](https://github.com/apache/incubator-seata/pull/7538)] unify DmdbTimestamp comparison via UTC Instant to prevent rollback failure
3436
- [[#7546](https://github.com/seata/seata/pull/7546)] fix client spring version compatible
@@ -38,12 +40,13 @@ Add changes here for all PR submitted to the 2.x branch.
3840
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] Fixed the issue where deserialization failed when the xss filter obtained the default keyword
3941
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] Fixed the SQL error in the datetime format time query in the global lock query
4042
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] fix the compatibility issue of yml configuration files
43+
- [[#7644](https://github.com/apache/incubator-seata/pull/7644)] fix the compatibility issue of spotless when java 25
4144
- [[#7662](https://github.com/apache/incubator-seata/pull/7662)] ensure visibility of rm and The methods in MockTest are executed in order
4245

4346

44-
4547
### optimize:
4648

49+
- [[#7460](https://github.com/apache/incubator-seata/pull/7460)] Remove hardcoded port configuration in core module test classes
4750
- [[#7478](https://github.com/apache/incubator-seata/pull/7484)] optimize: remove client id metric
4851
- [[#7557](https://github.com/seata/seata/pull/7557)] upgrade some npmjs dependencies
4952
- [[#7576](https://github.com/seata/seata/pull/7576)] Add empty push protection for Configuration
@@ -55,6 +58,8 @@ Add changes here for all PR submitted to the 2.x branch.
5558
- [[#7614](https://github.com/seata/seata/pull/7614)] update README.md
5659
- [[#7443](https://github.com/seata/seata/pull/7443)] Replace @LocalTCC with @SagaTransactional in the saga annotation pattern
5760
- [[#7645](https://github.com/seata/seata/pull/7645)] simplifying the relevant transport.* configuration types
61+
- [[#7673](https://github.com/apache/incubator-seata/pull/7673)] bump @babel/runtime from ^7.26.10 to ^7.27.0
62+
5863

5964
### security:
6065

@@ -69,6 +74,8 @@ Add changes here for all PR submitted to the 2.x branch.
6974
- [[#7580](https://github.com/seata/seata/pull/7580)] fix the exception caused by the disorder of test case execution order
7075
- [[#7584](https://github.com/apache/incubator-seata/pull/7584)] deflake ConsulConfigurationTest#testInitSeataConfig with short await/retry to absorb CI timing delay
7176
- [[#7610](https://github.com/apache/incubator-seata/pull/7610)] Enable Nacos integration tests when nacosCaseEnabled is true
77+
- [[#7672](https://github.com/apache/incubator-seata/pull/7672)] Add unit tests for the `seata-common` module
78+
- [[#7679](https://github.com/apache/incubator-seata/pull/7679)] fix old version connect timeout
7279

7380
### refactor:
7481

@@ -77,6 +84,7 @@ Add changes here for all PR submitted to the 2.x branch.
7784

7885
### doc:
7986

87+
- [[#7462](https://github.com/seata/seata/pull/7462)] improve TM module Javadoc with comprehensive English documentation
8088
- [[#7531](https://github.com/seata/seata/pull/7531)] Optimize the Readme and change documents
8189
- [[#7569](https://github.com/seata/seata/pull/7569)] Add hyperlink to CONTRIBUTING.md in pull request template
8290
- [[#7605](https://github.com/apache/incubator-seata/pull/7605)] Add the type of registry as seata in application.yml
@@ -97,8 +105,12 @@ Thanks to these contributors for their code commits. Please report an unintended
97105
- [keepConcentration](https://github.com/keepConcentration)
98106
- [sunheyi6](https://github.com/sunheyi6)
99107
- [WangzJi](https://github.com/WangzJi)
108+
- [unifolio0](https://github.com/unifolio0)
100109
- [Asuka-star](https://github.com/Asuka-star)
101110
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
102-
111+
- [jongmin-chung](https://github.com/jongmin-chung)
112+
- [jihun4452](https://github.com/jihun4452)
113+
- [psxjoy](https://github.com/psxjoy)
114+
- [dsomehan](https://github.com/dsomehan)
103115

104116
Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.

changes/zh-cn/2.x.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils支持达梦数据库
2727
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] 为 TableMetaRefreshHolder 实例引入清理 API
2828
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] 添加对 Jackson 序列化和反序列化 PostgreSQL 数组类型的支持
29+
- [[#7664](https://github.com/apache/incubator-seata/pull/7565)] 支持神通数据库的XA模式
2930

3031

3132
### bugfix:
3233

34+
- [[#6476](https://github.com/apache/seata/issues/6476)] 修复SerialArray equals()方法在二阶段回滚中多维数组比较的问题
3335
- [[#7482](https://github.com/apache/incubator-seata/pull/7482)] Github Action 工作流未运行相应的 Kotlin 测试
3436
- [[#7538](https://github.com/apache/incubator-seata/pull/7538)] 统一DmdbTimestamp比较方式,通过UTC比较,以防止回滚失败
3537
- [[#7546](https://github.com/seata/seata/pull/7546)] 修复客户端spring版本兼容
@@ -39,11 +41,13 @@
3941
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] 修复xss过滤器获取默认关键字时反序列化失败的问题
4042
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] 修复全局锁查询中的datetime时间格式时间查询sql错误
4143
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] 修复yml配置文件中对于整数的兼容问题
44+
- [[#7644](https://github.com/apache/incubator-seata/pull/7644)] 修复JAVA25时spotless的兼容性问题
4245
- [[#7662](https://github.com/apache/incubator-seata/pull/7662)] 确保 rm 的可见性,并且 MockTest 中的方法按顺序执行
4346

4447

4548
### optimize:
4649

50+
- [[#7460](https://github.com/apache/incubator-seata/pull/7460)] 移除 core 模块测试类中的硬编码端口配置
4751
- [[#7478](https://github.com/apache/incubator-seata/pull/7484)] 删除client id指标
4852
- [[#7557](https://github.com/seata/seata/pull/7557)] 升级 npmjs 依赖
4953
- [[#7576](https://github.com/seata/seata/pull/7576)] 针对配置变更增加空推保护
@@ -54,6 +58,8 @@
5458
- [[#7614](https://github.com/seata/seata/pull/7614)] 更新 README.md
5559
- [[#7443](https://github.com/seata/seata/pull/7443)] 将saga注释模式中的@LocalTCC替换为@SagaTransactional
5660
- [[#7645](https://github.com/seata/seata/pull/7645)] 简化相关的 transport.* 配置项类型
61+
- [[#7673](https://github.com/apache/incubator-seata/pull/7673)] 升级 @babel/runtime ^7.26.10 到 ^7.27.0
62+
5763

5864
### security:
5965

@@ -69,7 +75,8 @@
6975
- [[#7580](https://github.com/seata/seata/pull/7580)] 修复测试用例顺序错乱导致的异常
7076
- [[#7584](https://github.com/seata/seata/pull/7584)] 修复 ConsulConfigurationTest#testInitSeataConfig 在 CI 中由于等待/重试时间过短导致的不稳定问题
7177
- [[#7610](https://github.com/apache/incubator-seata/pull/7610)] 当nacosCaseEnabled为true时启用nacos集成测试
72-
78+
- [[#7672](https://github.com/apache/incubator-seata/pull/7672)] 增加 `seata-common` 模块的测试用例
79+
- [[#7679](https://github.com/apache/incubator-seata/pull/7679)] 修复旧版本协议测试超时问题
7380

7481
### refactor:
7582

@@ -78,6 +85,7 @@
7885

7986
### doc:
8087

88+
- [[#7462](https://github.com/seata/seata/pull/7462)] 完善 TM 模块的 Javadoc,补充全面的英文文档说明。
8189
- [[#7531](https://github.com/seata/seata/pull/7531)] 优化 Readme 和 change 文档
8290
- [[#7569](https://github.com/seata/seata/pull/7569)] 在拉取请求模板中添加 CONTRIBUTING.md 超链接
8391
- [[#7605](https://github.com/apache/incubator-seata/pull/7605)] 在application.yml中增加了seata作为注册中心的注释
@@ -98,8 +106,13 @@
98106
- [keepConcentration](https://github.com/keepConcentration)
99107
- [sunheyi6](https://github.com/sunheyi6)
100108
- [WangzJi](https://github.com/WangzJi)
109+
- [unifolio0](https://github.com/unifolio0)
101110
- [Asuka-star](https://github.com/Asuka-star)
102111
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
112+
- [jongmin-chung](https://github.com/jongmin-chung)
113+
- [jihun4452](https://github.com/jihun4452)
114+
- [psxjoy](https://github.com/psxjoy)
115+
- [dsomehan](https://github.com/dsomehan)
103116

104117

105118
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。

common/src/test/java/org/apache/seata/common/util/PageUtilTest.java

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import static org.junit.jupiter.api.Assertions.assertThrows;
3535
import static org.mockito.ArgumentMatchers.any;
3636
import static org.mockito.ArgumentMatchers.anyInt;
37+
import static org.mockito.ArgumentMatchers.eq;
3738
import static org.mockito.Mockito.doNothing;
3839

3940
/**
@@ -74,6 +75,7 @@ public void testPageSql() {
7475
assertEquals(PageUtil.pageSql(sourceSql, "oceanbase", 1, 5), mysqlTargetSql);
7576
assertEquals(PageUtil.pageSql(sourceSql, "dm", 1, 5), mysqlTargetSql);
7677
assertEquals(PageUtil.pageSql(sourceSql, "oscar", 1, 5), mysqlTargetSql);
78+
assertEquals(PageUtil.pageSql(sourceSql, "kingbase", 1, 5), mysqlTargetSql);
7779
assertEquals(PageUtil.pageSql(sourceSql, "oracle", 1, 5), oracleTargetSql);
7880
assertEquals(PageUtil.pageSql(sourceSql, "sqlserver", 1, 5), sqlserverTargetSql);
7981

@@ -92,6 +94,7 @@ void testCountSql() {
9294
assertEquals(PageUtil.countSql(sourceSql, "oceanbase"), targetSql);
9395
assertEquals(PageUtil.countSql(sourceSql, "dm"), targetSql);
9496
assertEquals(PageUtil.countSql(sourceSql, "oscar"), targetSql);
97+
assertEquals(PageUtil.countSql(sourceSql, "kingbase"), targetSql);
9598
assertEquals(PageUtil.countSql(sourceSql, "oracle"), targetSql);
9699
assertEquals(PageUtil.countSql(sourceSql, "sqlserver"), targetSql);
97100

@@ -189,4 +192,166 @@ public void getTimeStartSqlNotSupportedDBType() {
189192
IllegalArgumentException.class,
190193
() -> PageUtil.getTimeStartSql(notSupportedDBType, validTimeColumnName));
191194
}
195+
196+
@Test
197+
public void testGetTimeEndSqlSupportedDBTypes() {
198+
String[] supportedDBTypes = {"mysql", "oracle", "postgresql", "sqlserver", "dm", "oscar"};
199+
String expectedSQL = " and FLOOR(gmt_create/1000) <= ? ";
200+
201+
for (String dbType : supportedDBTypes) {
202+
assertEquals(expectedSQL, PageUtil.getTimeEndSql(dbType, validTimeColumnName));
203+
}
204+
}
205+
206+
@Test
207+
public void testGetTimeEndSqlNotSupportedDBType() {
208+
String notSupportedDBType = "xxx";
209+
assertThrows(
210+
IllegalArgumentException.class, () -> PageUtil.getTimeEndSql(notSupportedDBType, validTimeColumnName));
211+
}
212+
213+
@Test
214+
public void testGetDateTimeStartSqlMySQL() {
215+
String expectedSQL = " and UNIX_TIMESTAMP(gmt_create) >= ? ";
216+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("mysql", validTimeColumnName));
217+
}
218+
219+
@Test
220+
public void testGetDateTimeStartSqlPostgreSQL() {
221+
String expectedSQL = " and gmt_create >= TO_TIMESTAMP(?) ";
222+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("postgresql", validTimeColumnName));
223+
}
224+
225+
@Test
226+
public void testGetDateTimeStartSqlOracle() {
227+
String expectedSQL =
228+
" and gmt_create >= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
229+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("oracle", validTimeColumnName));
230+
}
231+
232+
@Test
233+
public void testGetDateTimeStartSqlSQLServer() {
234+
String expectedSQL = " and gmt_create >= DATEADD(SECOND, ?, '1970-01-01 00:00:00') ";
235+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("sqlserver", validTimeColumnName));
236+
}
237+
238+
@Test
239+
public void testGetDateTimeStartSqlDM() {
240+
String expectedSQL =
241+
" and gmt_create >= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
242+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("dm", validTimeColumnName));
243+
}
244+
245+
@Test
246+
public void testGetDateTimeStartSqlOscar() {
247+
String expectedSQL =
248+
" and gmt_create >= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
249+
assertEquals(expectedSQL, PageUtil.getDateTimeStartSql("oscar", validTimeColumnName));
250+
}
251+
252+
@Test
253+
public void testGetDateTimeStartSqlNotSupportedDBType() {
254+
String notSupportedDBType = "xxx";
255+
assertThrows(
256+
IllegalArgumentException.class,
257+
() -> PageUtil.getDateTimeStartSql(notSupportedDBType, validTimeColumnName));
258+
}
259+
260+
@Test
261+
public void testGetDateTimeEndSqlMySQL() {
262+
String expectedSQL = " and UNIX_TIMESTAMP(gmt_create) <= ? ";
263+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("mysql", validTimeColumnName));
264+
}
265+
266+
@Test
267+
public void testGetDateTimeEndSqlPostgreSQL() {
268+
String expectedSQL = " and gmt_create <= TO_TIMESTAMP(?) ";
269+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("postgresql", validTimeColumnName));
270+
}
271+
272+
@Test
273+
public void testGetDateTimeEndSqlOracle() {
274+
String expectedSQL =
275+
" and gmt_create <= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
276+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("oracle", validTimeColumnName));
277+
}
278+
279+
@Test
280+
public void testGetDateTimeEndSqlSQLServer() {
281+
String expectedSQL = " and gmt_create <= DATEADD(SECOND, ?, '1970-01-01 00:00:00') ";
282+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("sqlserver", validTimeColumnName));
283+
}
284+
285+
@Test
286+
public void testGetDateTimeEndSqlDM() {
287+
String expectedSQL =
288+
" and gmt_create <= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
289+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("dm", validTimeColumnName));
290+
}
291+
292+
@Test
293+
public void testGetDateTimeEndSqlOscar() {
294+
String expectedSQL =
295+
" and gmt_create <= TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS') + NUMTODSINTERVAL(?, 'SECOND') ";
296+
assertEquals(expectedSQL, PageUtil.getDateTimeEndSql("oscar", validTimeColumnName));
297+
}
298+
299+
@Test
300+
public void testGetDateTimeEndSqlNotSupportedDBType() {
301+
String notSupportedDBType = "xxx";
302+
assertThrows(
303+
IllegalArgumentException.class,
304+
() -> PageUtil.getDateTimeEndSql(notSupportedDBType, validTimeColumnName));
305+
}
306+
307+
@Test
308+
public void testCountSqlWithOrderByPostgreSQL() {
309+
String sourceSqlWithOrderBy = "select * from test where a = 1 order by id desc";
310+
String expectedSql = "select count(1) from test where a = 1 ";
311+
312+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithOrderBy, "postgresql"));
313+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithOrderBy, "kingbase"));
314+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithOrderBy, "sqlserver"));
315+
}
316+
317+
@Test
318+
public void testCountSqlWithoutOrderByPostgreSQL() {
319+
String sourceSqlWithoutOrderBy = "select * from test where a = 1";
320+
String expectedSql = "select count(1) from test where a = 1";
321+
322+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithoutOrderBy, "postgresql"));
323+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithoutOrderBy, "kingbase"));
324+
assertEquals(expectedSql, PageUtil.countSql(sourceSqlWithoutOrderBy, "sqlserver"));
325+
}
326+
327+
@Test
328+
public void testSetObjectWithSQLException() throws SQLException {
329+
List<Object> params = new ArrayList<>();
330+
params.add("test");
331+
332+
PreparedStatement preparedStatement = Mockito.mock(PreparedStatement.class);
333+
Mockito.doThrow(new SQLException("Test exception"))
334+
.when(preparedStatement)
335+
.setObject(anyInt(), any());
336+
337+
assertThrows(SQLException.class, () -> PageUtil.setObject(preparedStatement, params));
338+
}
339+
340+
@Test
341+
public void testSetObjectWithMultipleTypes() throws SQLException {
342+
List<Object> params = new ArrayList<>();
343+
params.add(new Date(System.currentTimeMillis()));
344+
params.add("testString");
345+
params.add(123);
346+
params.add(null);
347+
348+
PreparedStatement preparedStatement = Mockito.mock(PreparedStatement.class);
349+
doNothing().when(preparedStatement).setDate(anyInt(), any(java.sql.Date.class));
350+
doNothing().when(preparedStatement).setObject(anyInt(), any());
351+
352+
PageUtil.setObject(preparedStatement, params);
353+
354+
Mockito.verify(preparedStatement, Mockito.times(1)).setDate(eq(1), any(java.sql.Date.class));
355+
Mockito.verify(preparedStatement, Mockito.times(3)).setObject(anyInt(), any());
356+
}
192357
}

compatible/src/test/java/io/seata/rm/datasource/xa/DataSourceProxyXATest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.seata.rm.datasource.xa;
1818

1919
import com.alibaba.druid.pool.DruidDataSource;
20+
import com.alibaba.druid.pool.DruidStatementConnection;
2021
import com.mysql.jdbc.JDBC4MySQLConnection;
2122
import com.mysql.jdbc.jdbc2.optional.JDBC4ConnectionWrapper;
2223
import io.seata.core.context.RootContext;
@@ -66,6 +67,7 @@ public void testGetConnection() throws SQLException {
6667

6768
DruidDataSource druidDataSource = new DruidDataSource();
6869
druidDataSource.setDriver(driver);
70+
druidDataSource.setUrl("jdbc:mysql:xxx");
6971
DataSourceProxyXA dataSourceProxyXA = new DataSourceProxyXA(druidDataSource);
7072
RootContext.unbind();
7173
Connection connFromDataSourceProxyXA = dataSourceProxyXA.getConnection();
@@ -79,6 +81,9 @@ public void testGetConnection() throws SQLException {
7981
Assertions.assertTrue(wrappedConnection instanceof PooledConnection);
8082

8183
Connection wrappedPhysicalConn = ((PooledConnection) wrappedConnection).getConnection();
84+
if (wrappedPhysicalConn instanceof DruidStatementConnection) {
85+
wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection();
86+
}
8287
Assertions.assertSame(wrappedPhysicalConn, connection);
8388

8489
XAConnection xaConnection = connectionProxyXA.getWrappedXAConnection();
@@ -101,6 +106,7 @@ public void testGetMariaXaConnection() throws SQLException, ClassNotFoundExcepti
101106

102107
DruidDataSource druidDataSource = new DruidDataSource();
103108
druidDataSource.setDriver(driver);
109+
druidDataSource.setUrl("jdbc:mariadb:xxx");
104110
DataSourceProxyXA dataSourceProxyXA = new DataSourceProxyXA(druidDataSource);
105111
RootContext.unbind();
106112
Connection connFromDataSourceProxyXA = dataSourceProxyXA.getConnection();
@@ -115,6 +121,9 @@ public void testGetMariaXaConnection() throws SQLException, ClassNotFoundExcepti
115121
Assertions.assertTrue(wrappedConnection instanceof PooledConnection);
116122

117123
Connection wrappedPhysicalConn = ((PooledConnection) wrappedConnection).getConnection();
124+
if (wrappedPhysicalConn instanceof DruidStatementConnection) {
125+
wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection();
126+
}
118127
Assertions.assertSame(wrappedPhysicalConn, connection);
119128

120129
XAConnection xaConnection = connectionProxyXA.getWrappedXAConnection();

0 commit comments

Comments
 (0)