This is an automated email from the ASF dual-hosted git repository. jsbxyyx pushed a commit to branch 2.4.0 in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.4.0 by this push: new b638ed60a1 optimize: cherry pick some bugfix (#7431) b638ed60a1 is described below commit b638ed60a19a32f5b4b0399046c2f56439026203 Author: jsbxyyx <jsbx...@apache.org> AuthorDate: Wed Jun 11 10:36:31 2025 +0800 optimize: cherry pick some bugfix (#7431) --- changes/en-us/2.4.0.md | 1 + changes/zh-cn/2.4.0.md | 1 + changes/zh-cn/2.x.md | 2 ++ .../server/session/FileSessionManagerTest.java | 35 ++++++++-------------- .../file/FileTransactionStoreManagerTest.java | 12 ++++---- 5 files changed, 23 insertions(+), 28 deletions(-) diff --git a/changes/en-us/2.4.0.md b/changes/en-us/2.4.0.md index 905d0cefe7..0e1e3899c4 100644 --- a/changes/en-us/2.4.0.md +++ b/changes/en-us/2.4.0.md @@ -50,6 +50,7 @@ The version is updated as follows: - [[#7272](https://github.com/apache/incubator-seata/pull/7272)] fix: fix transaction info not display - [[#7277](https://github.com/apache/incubator-seata/pull/7277)] Fix MySQL jdbc driver can't be found properly - [[#7355](https://github.com/apache/incubator-seata/pull/7355)] fix: the drivers in the lib folder cannot be loaded +- [[#7397](https://github.com/apache/incubator-seata/pull/7397)] Resolve NullPointer and port binding errors ### optimize: diff --git a/changes/zh-cn/2.4.0.md b/changes/zh-cn/2.4.0.md index 18189215ce..310f18d3e4 100644 --- a/changes/zh-cn/2.4.0.md +++ b/changes/zh-cn/2.4.0.md @@ -49,6 +49,7 @@ Apache Seata(incubating) 是一款开源的分布式事务解决方案,提供 - [[#7272](https://github.com/apache/incubator-seata/pull/7272)] 修复全局事务显示问题 - [[#7277](https://github.com/apache/incubator-seata/pull/7277)] 修复MySQL jdbc驱动无法正常找到的问题 - [[#7355](https://github.com/apache/incubator-seata/pull/7355)] 修复驱动无法加载的问题 +- [[#7397](https://github.com/apache/incubator-seata/pull/7397)] 解决空指针和端口绑定错误 ### optimize: diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 0e3211eb1c..c0211521db 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -33,6 +33,7 @@ - [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] optimize XXX + ### security: - [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] upgrade XXX @@ -43,6 +44,7 @@ - [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] test XXX + ### refactor: - [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] refactor XXX diff --git a/server/src/test/java/org/apache/seata/server/session/FileSessionManagerTest.java b/server/src/test/java/org/apache/seata/server/session/FileSessionManagerTest.java index 45f2acaac1..8829d0d053 100644 --- a/server/src/test/java/org/apache/seata/server/session/FileSessionManagerTest.java +++ b/server/src/test/java/org/apache/seata/server/session/FileSessionManagerTest.java @@ -27,7 +27,6 @@ import java.util.stream.Stream; import javax.annotation.Resource; -import org.apache.seata.common.ConfigurationKeys; import org.apache.seata.common.XID; import org.apache.seata.common.loader.EnhancedServiceLoader; import org.apache.seata.common.result.PageResult; @@ -38,7 +37,6 @@ import org.apache.seata.core.model.BranchStatus; import org.apache.seata.core.model.BranchType; import org.apache.seata.core.model.GlobalStatus; import org.apache.seata.core.model.LockStatus; -import org.apache.seata.server.console.exception.ConsoleException; import org.apache.seata.server.console.entity.param.GlobalSessionParam; import org.apache.seata.server.console.service.BranchSessionService; import org.apache.seata.server.console.service.GlobalSessionService; @@ -46,17 +44,17 @@ import org.apache.seata.server.console.entity.vo.GlobalSessionVO; import org.apache.seata.server.storage.file.session.FileSessionManager; import org.apache.seata.server.util.StoreUtil; import org.apache.commons.lang.time.DateUtils; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; -import static org.apache.seata.common.DefaultValues.DEFAULT_SESSION_STORE_FILE_DIR; import static org.apache.seata.common.DefaultValues.DEFAULT_TX_GROUP; -import static org.apache.seata.server.session.SessionHolder.CONFIG; /** * The type File based session manager test. @@ -75,9 +73,6 @@ public class FileSessionManagerTest { @Resource(type = BranchSessionService.class) private BranchSessionService branchSessionService; - private static String sessionStorePath = CONFIG.getConfig(ConfigurationKeys.STORE_FILE_DIR, - DEFAULT_SESSION_STORE_FILE_DIR); - @BeforeAll public static void setUp(ApplicationContext context) { StoreUtil.deleteDataFile(); @@ -90,6 +85,15 @@ public class FileSessionManagerTest { } } + @BeforeEach + public void setUp(){ + SessionHolder.init(SessionMode.FILE); + } + @AfterEach + public void tearDown(){ + SessionHolder.destroy(); + } + /** * Add global session test. * @@ -292,11 +296,7 @@ public class FileSessionManagerTest { @ParameterizedTest @MethodSource("globalSessionsWithPageResultProvider") public void findGlobalSessionsWithPageResultTest(List<GlobalSession> globalSessions) throws Exception { - SessionHolder.getRootSessionManager().destroy(); - SessionHolder.init(SessionMode.FILE); - try { - SessionHolder.init(SessionMode.FILE); final SessionManager sessionManager = SessionHolder.getRootSessionManager(); // make sure sessionMaanager is empty Collection<GlobalSession> sessions = sessionManager.allSessions(); @@ -433,7 +433,6 @@ public class FileSessionManagerTest { @MethodSource("globalSessionForLockTestProvider") public void stopGlobalSessionTest(List<GlobalSession> globalSessions) throws Exception { try { - SessionHolder.init(SessionMode.FILE); for (GlobalSession globalSession : globalSessions) { globalSession.begin(); } @@ -463,19 +462,14 @@ public class FileSessionManagerTest { @MethodSource("globalSessionForLockTestProvider") public void changeGlobalSessionTest(List<GlobalSession> globalSessions) throws Exception { try { - SessionHolder.init(SessionMode.FILE); for (GlobalSession globalSession : globalSessions) { globalSession.begin(); } Assertions.assertThrows(IllegalArgumentException.class, () -> globalSessionService.changeGlobalStatus(globalSessions.get(0).getXid())); - GlobalSession globalSession = globalSessions.get(1); - globalSession.changeGlobalStatus(GlobalStatus.CommitFailed); - String xid = globalSession.getXid(); -// Assertions.assertThrows(ConsoleException.class, () -> globalSessionService.changeGlobalStatus(xid)); - globalSession.changeGlobalStatus(GlobalStatus.RollbackFailed); - Assertions.assertThrows(ConsoleException.class, () -> globalSessionService.changeGlobalStatus(xid)); + Assertions.assertEquals(GlobalStatus.Begin, globalSessions.get(0).getStatus()); + // TODO: After implementing robust support for concurrent multi‑module tests, add tests to verify that globalSession transitions to FAIL_COMMIT_STATUS and FAIL_ROLLBACK_STATUS. } finally { for (GlobalSession globalSession : globalSessions) { globalSession.setStatus(GlobalStatus.Committed); @@ -488,7 +482,6 @@ public class FileSessionManagerTest { @MethodSource("globalSessionForLockTestProvider") public void startGlobalSessionTest(List<GlobalSession> globalSessions) throws Exception { try { - SessionHolder.init(SessionMode.FILE); for (GlobalSession globalSession : globalSessions) { globalSession.begin(); } @@ -587,7 +580,6 @@ public class FileSessionManagerTest { @MethodSource("branchSessionsProvider") public void stopBranchRetryTest(GlobalSession globalSession) throws Exception { try { - SessionHolder.init(SessionMode.FILE); globalSession.begin(); // wrong param for xid and branchId Assertions.assertThrows(IllegalArgumentException.class, @@ -622,7 +614,6 @@ public class FileSessionManagerTest { @MethodSource("branchSessionsProvider") public void restartBranchFailRetryTest(GlobalSession globalSession) throws Exception { try { - SessionHolder.init(SessionMode.FILE); globalSession.begin(); List<BranchSession> branchSessions = globalSession.getBranchSessions(); // wrong status for branch transaction diff --git a/server/src/test/java/org/apache/seata/server/store/file/FileTransactionStoreManagerTest.java b/server/src/test/java/org/apache/seata/server/store/file/FileTransactionStoreManagerTest.java index dca761e123..9c5a8915cc 100644 --- a/server/src/test/java/org/apache/seata/server/store/file/FileTransactionStoreManagerTest.java +++ b/server/src/test/java/org/apache/seata/server/store/file/FileTransactionStoreManagerTest.java @@ -26,9 +26,9 @@ import java.util.List; import org.apache.seata.common.store.SessionMode; import org.apache.seata.server.session.SessionHolder; import org.assertj.core.util.Files; -import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.boot.test.context.SpringBootTest; @@ -50,12 +50,12 @@ import org.springframework.context.ApplicationContext; @SpringBootTest public class FileTransactionStoreManagerTest { - @BeforeAll - public static void init(ApplicationContext context){ + @BeforeEach + public void setUp(){ SessionHolder.init(SessionMode.FILE); } - @AfterAll - public static void destroy(){ + @AfterEach + public void tearDown(){ SessionHolder.destroy(); } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org