From de4b303a45006276408ba056f14c2956dc31d40d Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 19 Aug 2024 14:33:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DSQL=E6=95=B0=E6=8D=AE=E6=BA=90=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=97=B6=E6=97=A0=E6=B3=95=E6=94=B6=E5=88=B0=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1045163 --user=赵勇 [接口测试]github#32619运行环境中不配置数据源链接或配错误的链接并且用例中写了SQL脚本时,执行用例会卡死。 https://www.tapd.cn/55049933/s/1564930 Signed-off-by: fit2-zhao --- .../request/processors/post/MsJDBCPostProcessor.java | 5 +++++ .../request/processors/pre/MsJDBCPreProcessor.java | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java index c556c0f66d..3faf0c85ac 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java @@ -73,10 +73,15 @@ public class MsJDBCPostProcessor extends MsTestElement { LoggerUtil.error(this.getName() + ",未找到数据源", JSONUtil.toJSONString(config)); } } + if (this.dataSource == null) { + return; + } + JDBCPostProcessor jdbcPostProcessor = jdbcPostProcessor(config); final HashTree samplerHashTree = tree.add(jdbcPostProcessor); tree.add(ElementUtil.jdbcDataSource(jdbcPostProcessor.getDataSource(), this.dataSource)); + ElementUtil.jdbcArguments(this.getName(), this.getVariables(), tree); if (CollectionUtils.isNotEmpty(hashTree)) { hashTree.forEach(el -> { diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java index 0ca20d3dff..e38cc430a2 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java @@ -7,7 +7,6 @@ import io.metersphere.api.dto.scenario.DatabaseConfig; import io.metersphere.api.dto.scenario.KeyValue; import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.constants.RequestTypeConstants; -import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.JSONUtil; import io.metersphere.commons.vo.JDBCProcessorVO; @@ -74,6 +73,10 @@ public class MsJDBCPreProcessor extends MsTestElement { } } + if (this.dataSource == null) { + return; + } + JDBCPreProcessor jdbcPreProcessor = jdbcPreProcessor(config); final HashTree samplerHashTree = tree.add(jdbcPreProcessor); // 数据源