This is an automated email from the ASF dual-hosted git repository. jimin pushed a commit to branch 2.x in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push: new e0e8de1559 test: fix port of mock server (#7540) e0e8de1559 is described below commit e0e8de1559ee2289ff1cc9aba58c333a5d7dd946 Author: justabug <bug...@users.noreply.github.com> AuthorDate: Wed Jul 23 10:23:45 2025 +0800 test: fix port of mock server (#7540) --- changes/en-us/2.x.md | 1 + changes/zh-cn/2.x.md | 1 + .../java/org/apache/seata/mockserver/MockServer.java | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index e1b3b324ac..175b5979b6 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -39,6 +39,7 @@ Add changes here for all PR submitted to the 2.x branch. ### test: - [[#7541](https://github.com/seata/seata/pull/7541)] fix jakarta UT failed in jdk17+ +- [[#7540](https://github.com/seata/seata/pull/7540)] fix port of mock server ### refactor: diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index d4b052c678..f9aaef42bc 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -39,6 +39,7 @@ ### test: - [[#7541](https://github.com/seata/seata/pull/7541)] 修复 jakarta 依赖在 jdk17+ 单测失败问题 +- [[#7540](https://github.com/seata/seata/pull/7540)] 修复mock server端口冲突问题 ### refactor: diff --git a/mock-server/src/main/java/org/apache/seata/mockserver/MockServer.java b/mock-server/src/main/java/org/apache/seata/mockserver/MockServer.java index 77385beca5..195881f58c 100644 --- a/mock-server/src/main/java/org/apache/seata/mockserver/MockServer.java +++ b/mock-server/src/main/java/org/apache/seata/mockserver/MockServer.java @@ -34,8 +34,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import static org.apache.seata.common.ConfigurationKeys.ENV_SEATA_PORT_KEY; - /** * The type Mock Server. */ @@ -49,7 +47,8 @@ public class MockServer { private static volatile boolean inited = false; - public static final int DEFAULT_PORT = 8091; + public static final int MOCK_DEFAULT_PORT = 10091; + public static String MOCK_SEATA_PORT_KEY = "SEATA_MOCK_PORT"; /** * The entry point of application. @@ -58,8 +57,16 @@ public class MockServer { */ public static void main(String[] args) { SpringApplication.run(MockServer.class, args); + int port = NumberUtils.toInt(System.getenv(MOCK_SEATA_PORT_KEY), MOCK_DEFAULT_PORT); + + if (args != null && args.length > 0) { + try { + port = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + LOGGER.error("Invalid port number provided, using default port: {}", port, e); + } + } - int port = NumberUtils.toInt(System.getenv(ENV_SEATA_PORT_KEY), DEFAULT_PORT); start(port); } @@ -101,6 +108,7 @@ public class MockServer { })); LOGGER.info( "pid info: " + ManagementFactory.getRuntimeMXBean().getName()); + LOGGER.info("MockServer started on port: {}", port); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org