Skip to content

Commit 75d163b

Browse files
authored
Merge branch '2.x' into 250625
2 parents e776711 + 3f86ccd commit 75d163b

File tree

36 files changed

+1409
-326
lines changed

36 files changed

+1409
-326
lines changed

changes/en-us/2.x.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Add changes here for all PR submitted to the 2.x branch.
2323
- [[#7485](https://github.com/apache/incubator-seata/pull/7485)] Add http request filter for seata-server
2424
- [[#7509](https://github.com/apache/incubator-seata/pull/7509)] Reuse connection to merge branch transactions
2525
- [[#7492](https://github.com/apache/incubator-seata/pull/7492)] upgrade HTTP client in common module to support HTTP/2
26-
[[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils add support for DM Database
26+
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils add support for DM Database
27+
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] Introduce Cleanup API for TableMetaRefreshHolder Instance
28+
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] add support for Jackson serialization and deserialization of PostgreSQL array types
2729

2830
### bugfix:
2931

@@ -37,6 +39,7 @@ Add changes here for all PR submitted to the 2.x branch.
3739
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] Fixed the issue where deserialization failed when the xss filter obtained the default keyword
3840
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] Fixed the SQL error in the datetime format time query in the global lock query
3941
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] fix the compatibility issue of yml configuration files
42+
- [[#7662](https://github.com/apache/incubator-seata/pull/7662)] ensure visibility of rm and The methods in MockTest are executed in order
4043

4144
### optimize:
4245

@@ -50,10 +53,12 @@ Add changes here for all PR submitted to the 2.x branch.
5053
- [[#7603](https://github.com/seata/seata/pull/7603)] upgrade Apache Tomcat dependency from 9.0.106 to 9.0.108
5154
- [[#7614](https://github.com/seata/seata/pull/7614)] update README.md
5255
- [[#7443](https://github.com/seata/seata/pull/7443)] Replace @LocalTCC with @SagaTransactional in the saga annotation pattern
56+
- [[#7645](https://github.com/seata/seata/pull/7645)] simplifying the relevant transport.* configuration types
5357

5458
### security:
5559

56-
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] upgrade XXX
60+
- [[#7632](https://github.com/apache/incubator-seata/pull/7632)] upgrade sha.js to version 2.4.12
61+
- [[#7633](https://github.com/apache/incubator-seata/pull/7633)] Upgrade cipher-base to version 1.0.6
5762

5863

5964
### test:
@@ -63,6 +68,7 @@ Add changes here for all PR submitted to the 2.x branch.
6368
- [[#7580](https://github.com/seata/seata/pull/7580)] fix the exception caused by the disorder of test case execution order
6469
- [[#7584](https://github.com/apache/incubator-seata/pull/7584)] deflake ConsulConfigurationTest#testInitSeataConfig with short await/retry to absorb CI timing delay
6570
- [[#7610](https://github.com/apache/incubator-seata/pull/7610)] Enable Nacos integration tests when nacosCaseEnabled is true
71+
- [[#7672](https://github.com/apache/incubator-seata/pull/7672)] Add unit tests for the `seata-common` module
6672

6773
### refactor:
6874

@@ -71,9 +77,11 @@ Add changes here for all PR submitted to the 2.x branch.
7177

7278
### doc:
7379

80+
- [[#7462](https://github.com/seata/seata/pull/7462)] improve TM module Javadoc with comprehensive English documentation
7481
- [[#7531](https://github.com/seata/seata/pull/7531)] Optimize the Readme and change documents
7582
- [[#7569](https://github.com/seata/seata/pull/7569)] Add hyperlink to CONTRIBUTING.md in pull request template
7683
- [[#7605](https://github.com/apache/incubator-seata/pull/7605)] Add the type of registry as seata in application.yml
84+
- [[#7625](https://github.com/apache/incubator-seata/pull/7625)] Polish Javadoc for @EnableAutoDataSourceProxy and DefaultFailureHandlerImpl
7785

7886

7987
Thanks to these contributors for their code commits. Please report an unintended omission.
@@ -91,6 +99,8 @@ Thanks to these contributors for their code commits. Please report an unintended
9199
- [sunheyi6](https://github.com/sunheyi6)
92100
- [WangzJi](https://github.com/WangzJi)
93101
- [unifolio0](https://github.com/unifolio0)
94-
102+
- [Asuka-star](https://github.com/Asuka-star)
103+
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
104+
- [psxjoy](https://github.com/psxjoy)
95105

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

changes/zh-cn/2.x.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- [[#7509](https://github.com/apache/incubator-seata/pull/7509)] 复用连接合并分支事务
2525
- [[#7492](https://github.com/apache/incubator-seata/pull/7492)] 升级 common 模块中的 HTTP 客户端以支持 HTTP/2
2626
- [[#7551](https://github.com/apache/incubator-seata/pull/7551)] XAUtils支持达梦数据库
27+
- [[#7559](https://github.com/apache/incubator-seata/pull/7559)] 为 TableMetaRefreshHolder 实例引入清理 API
28+
- [[#7669](https://github.com/apache/incubator-seata/pull/7669)] 添加对 Jackson 序列化和反序列化 PostgreSQL 数组类型的支持
2729

2830

2931
### bugfix:
@@ -38,6 +40,7 @@
3840
- [[#7596](https://github.com/apache/incubator-seata/pull/7596)] 修复xss过滤器获取默认关键字时反序列化失败的问题
3941
- [[#7613](https://github.com/apache/incubator-seata/pull/7613)] 修复全局锁查询中的datetime时间格式时间查询sql错误
4042
- [[#7624](https://github.com/apache/incubator-seata/pull/7624)] 修复yml配置文件中对于整数的兼容问题
43+
- [[#7662](https://github.com/apache/incubator-seata/pull/7662)] 确保 rm 的可见性,并且 MockTest 中的方法按顺序执行
4144

4245

4346
### optimize:
@@ -51,10 +54,13 @@
5154
- [[#7603](https://github.com/seata/seata/pull/7603)] 将Apache Tomcat依赖项从9.0.106升级到9.0.108
5255
- [[#7614](https://github.com/seata/seata/pull/7614)] 更新 README.md
5356
- [[#7443](https://github.com/seata/seata/pull/7443)] 将saga注释模式中的@LocalTCC替换为@SagaTransactional
57+
- [[#7645](https://github.com/seata/seata/pull/7645)] 简化相关的 transport.* 配置项类型
5458

5559
### security:
5660

57-
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 升级 XXX
61+
- [[#7632](https://github.com/apache/incubator-seata/pull/7632)] 升级sha.js为2.4.12
62+
- [[#7633](https://github.com/apache/incubator-seata/pull/7633)] 升级cipher-base为1.0.6
63+
5864

5965
### test:
6066

@@ -64,6 +70,7 @@
6470
- [[#7580](https://github.com/seata/seata/pull/7580)] 修复测试用例顺序错乱导致的异常
6571
- [[#7584](https://github.com/seata/seata/pull/7584)] 修复 ConsulConfigurationTest#testInitSeataConfig 在 CI 中由于等待/重试时间过短导致的不稳定问题
6672
- [[#7610](https://github.com/apache/incubator-seata/pull/7610)] 当nacosCaseEnabled为true时启用nacos集成测试
73+
- [[#7672](https://github.com/apache/incubator-seata/pull/7672)] 增加 `seata-common` 模块的测试用例
6774

6875

6976
### refactor:
@@ -73,9 +80,11 @@
7380

7481
### doc:
7582

83+
- [[#7462](https://github.com/seata/seata/pull/7462)] 完善 TM 模块的 Javadoc,补充全面的英文文档说明。
7684
- [[#7531](https://github.com/seata/seata/pull/7531)] 优化 Readme 和 change 文档
7785
- [[#7569](https://github.com/seata/seata/pull/7569)] 在拉取请求模板中添加 CONTRIBUTING.md 超链接
7886
- [[#7605](https://github.com/apache/incubator-seata/pull/7605)] 在application.yml中增加了seata作为注册中心的注释
87+
- [[#7625](https://github.com/apache/incubator-seata/pull/7625)] 改进 @EnableAutoDataSourceProxy 和 DefaultFailureHandlerImpl 的 Javadoc
7988

8089

8190
非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。
@@ -93,6 +102,8 @@
93102
- [sunheyi6](https://github.com/sunheyi6)
94103
- [WangzJi](https://github.com/WangzJi)
95104
- [unifolio0](https://github.com/unifolio0)
96-
105+
- [Asuka-star](https://github.com/Asuka-star)
106+
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
107+
- [psxjoy](https://github.com/psxjoy)
97108

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

common/src/main/java/org/apache/seata/common/ConfigurationKeys.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,13 @@ public interface ConfigurationKeys {
667667
/**
668668
* The constant TRANSPORT_TYPE
669669
*/
670+
@Deprecated
670671
String TRANSPORT_TYPE = TRANSPORT_PREFIX + "type";
671672

672673
/**
673674
* The constant TRANSPORT_SERVER
674675
*/
676+
@Deprecated
675677
String TRANSPORT_SERVER = TRANSPORT_PREFIX + "server";
676678

677679
/**

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/spi/SPITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void testRmSPIOrder() {
3737
Assertions.assertNotNull(list);
3838
ResourceManager resourceManager = list.get(list.size() - 1);
3939
Assertions.assertEquals(
40-
"io.seata.saga.rm.SagaResourceManager",
40+
"org.apache.seata.saga.rm.SagaResourceManager",
4141
resourceManager.getClass().getName());
4242
}
4343
}

compressor/seata-compressor-deflater/src/main/java/org/apache/seata/compressor/deflater/DeflaterUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public static byte[] compress(byte[] bytes) {
3131
if (bytes == null) {
3232
throw new NullPointerException("bytes is null");
3333
}
34-
int lenght = 0;
34+
int length = 0;
3535
Deflater deflater = new Deflater();
3636
deflater.setInput(bytes);
3737
deflater.finish();
3838
byte[] outputBytes = new byte[BUFFER_SIZE];
3939
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
4040
while (!deflater.finished()) {
41-
lenght = deflater.deflate(outputBytes);
42-
bos.write(outputBytes, 0, lenght);
41+
length = deflater.deflate(outputBytes);
42+
bos.write(outputBytes, 0, length);
4343
}
4444
deflater.end();
4545
return bos.toByteArray();

0 commit comments

Comments
 (0)