From 0d66e08f98f04ba258e8121ac48172b1b93f017f Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 23 Nov 2022 20:44:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=AF=BC=E5=87=BA=E6=AD=A5=E9=AA=A4=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E5=85=BC=E5=AE=B9=E6=97=A7=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020198 --user=陈建星 【测试跟踪】github#20007老版本升级新版本2.3.1后,测试用例--steps字段中未对预期结果为空时做兼容处理,导致测试用例导出报空指针错误 https://www.tapd.cn/55049933/s/1303458 --- .../main/java/io/metersphere/service/TestCaseService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index 3f961ccd09..bb856f1566 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -1771,11 +1771,11 @@ public class TestCaseService { for (int j = 0; j < jsonArray.size(); j++) { // 将步骤存储起来,之后生成多条数据,再合并单元格 Map item = (Map) jsonArray.get(j); - String stepDesc = item.get("desc").toString(); - String stepResult = item.get("result").toString(); + String stepDesc = Optional.ofNullable(item.get("desc")).orElse(StringUtils.EMPTY).toString(); + String stepResult = Optional.ofNullable(item.get("result")).orElse(StringUtils.EMPTY).toString(); if (StringUtils.isNotBlank(stepDesc) || StringUtils.isNotBlank(stepResult)) { - stepDescList.add(Optional.ofNullable(stepDesc).orElse(StringUtils.EMPTY)); - stepResultList.add(Optional.ofNullable(stepResult).orElse(StringUtils.EMPTY)); + stepDescList.add(stepDesc); + stepResultList.add(stepResult); } } }