fix(接口测试): 修复SQL数据源为空时无法收到结果问题

--bug=1045163 --user=赵勇 [接口测试]github#32619运行环境中不配置数据源链接或配错误的链接并且用例中写了SQL脚本时,执行用例会卡死。 https://www.tapd.cn/55049933/s/1564930

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2024-08-19 14:33:32 +08:00 committed by Craftsman
parent cf08833361
commit de4b303a45
2 changed files with 9 additions and 1 deletions

View File

@ -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 -> {

View File

@ -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);
// 数据源