From 754f067cddeb72da0c0e67116716250a77dc7b40 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 25 Nov 2020 10:36:30 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AE=8C=E5=96=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/jmeter/APIBackendListenerClient.java | 4 ++-- .../api/parse/JmeterDocumentParser.java | 2 +- .../api/service/APITestService.java | 6 ++--- .../commons/utils/CompressUtils.java | 4 ++-- .../commons/utils/ScriptEngineUtils.java | 4 ++-- .../notice/service/DingTaskService.java | 2 +- .../notice/service/MailService.java | 22 +++++++++---------- .../notice/service/WxChatTaskService.java | 2 +- .../performance/engine/EngineFactory.java | 4 ++-- .../engine/docker/DockerTestEngine.java | 4 ++-- .../notice/PerformanceNoticeTask.java | 2 +- .../service/PerformanceTestService.java | 4 ++-- .../metersphere/service/JarConfigService.java | 2 +- .../service/SystemParameterService.java | 2 +- .../service/TestResourcePoolService.java | 6 ++--- .../track/service/IssuesService.java | 2 +- .../track/service/TestCaseCommentService.java | 2 +- .../track/service/TestCaseReviewService.java | 8 +++---- .../track/service/TestPlanService.java | 8 +++---- .../websocket/ReportWebSocket.java | 2 +- 20 files changed, 46 insertions(+), 46 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index eb66714e05..026b1fb1f6 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -161,13 +161,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name()); } } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } try { sendTask(report, testResult); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java index efa1771c8c..3e6b191bfd 100644 --- a/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/api/parse/JmeterDocumentParser.java @@ -50,7 +50,7 @@ public class JmeterDocumentParser { } return documentToBytes(document); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); return source; } } diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 85da5303d1..9dcac1c29f 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -131,7 +131,7 @@ public class APITestService { file.createNewFile(); FileUtil.copyStream(in, out); } catch (IOException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("upload_fail")); } } @@ -174,7 +174,7 @@ public class APITestService { try { FileUtil.copyDir(sourceFile, new File(targetDir)); } catch (IOException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("upload_fail")); } } @@ -437,7 +437,7 @@ public class APITestService { bytes = JmeterDocumentParser.parse(bytes); is = new ByteArrayInputStream(bytes); } catch (IOException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } jMeterService.run(request.getId(), reportId, is); diff --git a/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java b/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java index 04017e0fb4..24490d1f97 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java @@ -88,7 +88,7 @@ public class CompressUtils { gzip.finish(); return obj.toByteArray(); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); return data; } } @@ -116,7 +116,7 @@ public class CompressUtils { baos.flush(); return baos.toByteArray(); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); return data; } } diff --git a/backend/src/main/java/io/metersphere/commons/utils/ScriptEngineUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ScriptEngineUtils.java index 138d01c655..599d1b5234 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ScriptEngineUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ScriptEngineUtils.java @@ -18,7 +18,7 @@ public class ScriptEngineUtils { String script = IOUtils.toString(ScriptEngineUtils.class.getResource("/javascript/func.js"), StandardCharsets.UTF_8); engine.eval(script); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -26,7 +26,7 @@ public class ScriptEngineUtils { try { return engine.eval("calculate('" + input + "')").toString(); } catch (ScriptException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); return input; } } diff --git a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java index c2d56193ba..9f2047f6ce 100644 --- a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java @@ -66,7 +66,7 @@ public class DingTaskService { try { response = client.execute(request); } catch (ApiException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } System.out.println(response.getErrcode()); } diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index aa353c816e..1dea8d0ea8 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -65,7 +65,7 @@ public class MailService { } sendApiOrLoadNotification(addresseeIdList(messageDetail, userIds, eventType), context, performanceTemplate, loadTestReport.getTriggerMode()); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -86,7 +86,7 @@ public class MailService { } sendApiOrLoadNotification(addresseeIdList(messageDetail, userIds, eventType), context, apiTemplate, apiTestReport.getTriggerMode()); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -118,7 +118,7 @@ public class MailService { try { javaMailSender.send(mimeMessage); } catch (MailException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } //测试评审 @@ -129,7 +129,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewEnd.html"), StandardCharsets.UTF_8); sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -139,7 +139,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewDelete.html"), StandardCharsets.UTF_8); sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -156,7 +156,7 @@ public class MailService { String commentTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewComments.html"), StandardCharsets.UTF_8); sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, commentTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -166,7 +166,7 @@ public class MailService { String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/ReviewInitiate.html"), StandardCharsets.UTF_8); sendReviewNotice(addresseeIdList(messageDetail, userIds, eventType), context, reviewerTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -205,7 +205,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanStart.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -217,7 +217,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanEnd.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -229,7 +229,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanDelete.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -266,7 +266,7 @@ public class MailService { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/IssuesCreate.html"), StandardCharsets.UTF_8); sendIssuesNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java index 2de762ead7..89249b2b43 100644 --- a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java @@ -59,7 +59,7 @@ public class WxChatTaskService { SendResult result = WxChatbotClient.send(Webhook, message); System.out.println(result); } catch (IOException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java index 97a14aee04..4b2d6040b3 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java +++ b/backend/src/main/java/io/metersphere/performance/engine/EngineFactory.java @@ -139,10 +139,10 @@ public class EngineFactory { String content = engineSourceParser.parse(engineContext, source); engineContext.setContent(content); } catch (MSException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); throw e; } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(e); } diff --git a/backend/src/main/java/io/metersphere/performance/engine/docker/DockerTestEngine.java b/backend/src/main/java/io/metersphere/performance/engine/docker/DockerTestEngine.java index 1db5e194ae..3afd797fd7 100644 --- a/backend/src/main/java/io/metersphere/performance/engine/docker/DockerTestEngine.java +++ b/backend/src/main/java/io/metersphere/performance/engine/docker/DockerTestEngine.java @@ -64,10 +64,10 @@ public class DockerTestEngine extends AbstractEngine { try { context = EngineFactory.createContext(loadTest, resource.getId(), ratio, this.getStartTime(), this.getReportId(), resourceIndex); } catch (MSException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); throw e; } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(e); } diff --git a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java index db8cbbd74a..b3ca8d57c4 100644 --- a/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java +++ b/backend/src/main/java/io/metersphere/performance/notice/PerformanceNoticeTask.java @@ -65,7 +65,7 @@ public class PerformanceNoticeTask { //查询定时任务是否关闭 Thread.sleep(1000 * 30);// 每分钟检查 loadtest 的状态 } catch (InterruptedException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } }); diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index fe338d2858..544a2eaefd 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -258,7 +258,7 @@ public class PerformanceTestService { soc.close(); } } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("load_test_kafka_invalid")); } } @@ -304,7 +304,7 @@ public class PerformanceTestService { } catch (MSException e) { // 启动失败之后清理任务 engine.stop(); - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); loadTest.setStatus(PerformanceTestStatus.Error.name()); loadTest.setDescription(e.getMessage()); loadTestMapper.updateByPrimaryKeySelective(loadTest); diff --git a/backend/src/main/java/io/metersphere/service/JarConfigService.java b/backend/src/main/java/io/metersphere/service/JarConfigService.java index f278fbd069..fe3f499458 100644 --- a/backend/src/main/java/io/metersphere/service/JarConfigService.java +++ b/backend/src/main/java/io/metersphere/service/JarConfigService.java @@ -119,7 +119,7 @@ public class JarConfigService { file.createNewFile(); FileUtil.copyStream(in, out); } catch (IOException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("upload_fail")); } return filePath; diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 7a9a42e66c..e58e268726 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -107,7 +107,7 @@ public class SystemParameterService { try { javaMailSender.testConnection(); } catch (MessagingException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("connection_failed")); } } diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java index d43ae6759d..ce6aef6ac0 100644 --- a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -135,7 +135,7 @@ public class TestResourcePoolService { MSException.throwException("Resource Pool is invalid."); } } catch (IllegalAccessException | InvocationTargetException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -161,7 +161,7 @@ public class TestResourcePoolService { testResourcePoolDTO.setResources(testResources); testResourcePoolDTOS.add(testResourcePoolDTO); } catch (IllegalAccessException | InvocationTargetException e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } }); return testResourcePoolDTOS; @@ -210,7 +210,7 @@ public class TestResourcePoolService { ResponseEntity entity = restTemplateWithTimeOut.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), String.class); return HttpStatus.OK.equals(entity.getStatusCode()); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); return false; } } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index dc84ad5bf8..fbe799157f 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -116,7 +116,7 @@ public class IssuesService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java index 2ed274c442..b51e6716c4 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java @@ -84,7 +84,7 @@ public class TestCaseCommentService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index a955e9c6c6..617295d1f9 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -127,7 +127,7 @@ public class TestCaseReviewService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -205,7 +205,7 @@ public class TestCaseReviewService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -316,7 +316,7 @@ public class TestCaseReviewService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -466,7 +466,7 @@ public class TestCaseReviewService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index b4cb1346c3..35827a7299 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -137,7 +137,7 @@ public class TestPlanService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } @@ -188,7 +188,7 @@ public class TestPlanService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } return i; @@ -272,7 +272,7 @@ public class TestPlanService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } return num; } @@ -513,7 +513,7 @@ public class TestPlanService { } }); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } diff --git a/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java b/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java index 33c072fadf..b34c38d67c 100644 --- a/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java +++ b/backend/src/main/java/io/metersphere/websocket/ReportWebSocket.java @@ -106,7 +106,7 @@ public class ReportWebSocket { } Thread.sleep(20 * 1000L); } catch (Exception e) { - LogUtil.error(e); + LogUtil.error(e.getMessage(), e); } } }