From dbfbf12ef29c418edb27b33d17988d205e648f02 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 6 Nov 2023 13:27:59 +0800 Subject: [PATCH] chore: fix typo --- .../system/utils/TaskRunnerClient.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/utils/TaskRunnerClient.java b/backend/services/system-setting/src/main/java/io/metersphere/system/utils/TaskRunnerClient.java index b56940e1d1..788757676b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/utils/TaskRunnerClient.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/utils/TaskRunnerClient.java @@ -40,9 +40,8 @@ public class TaskRunnerClient { ResponseEntity entity = restTemplateWithTimeOut.exchange(u, HttpMethod.GET, httpEntity, ResultHolder.class); return entity.getBody(); }; - // 首次调用 - ResultHolder body = action.execute(url, null); - return retry(url, body, action); + + return retry(url, null, action); } public static ResultHolder post(String url, Object requestBody) throws Exception { @@ -56,20 +55,22 @@ public class TaskRunnerClient { restTemplateWithTimeOut.postForEntity(url, httpEntity, ResultHolder.class); return entity.getBody(); }; - // 首次调用 - ResultHolder body = action.execute(url, requestBody); - return retry(url, body, action); + + return retry(url, requestBody, action); } - private static ResultHolder retry(String url, ResultHolder body, Action action) throws Exception { + private static ResultHolder retry(String url, Object requestBody, Action action) throws Exception { + // 首次调用 + ResultHolder body = action.execute(url, requestBody); if (body != null && body.getCode() == MsHttpResultCode.SUCCESS.getCode()) { return body; } + // 增加token失败重试 for (int i = 0; i < retryCount; i++) { TimeUnit.MILLISECONDS.sleep(300); - body = action.execute(url, null); + body = action.execute(url, requestBody); // 重试后检查是否成功 if (body != null && body.getCode() == MsHttpResultCode.SUCCESS.getCode()) { return body;