From c1b9d95c41d03155afc11bae13e450c607a29f68 Mon Sep 17 00:00:00 2001 From: "zhczyx@163.com" Date: Thu, 11 Jun 2026 10:51:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(http):=20=E5=A4=84=E7=90=86=E9=9D=9EJSON?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=9A=84API=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加异常捕获逻辑,当API返回非JSON内容时不会解析失败,而是返回默认的成功响应 --- .../com/aeon/tcp/utils/DefaultHttpRequestUtil.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/aeon/tcp/utils/DefaultHttpRequestUtil.java b/src/main/java/com/aeon/tcp/utils/DefaultHttpRequestUtil.java index 8b3506f..3e9fca6 100644 --- a/src/main/java/com/aeon/tcp/utils/DefaultHttpRequestUtil.java +++ b/src/main/java/com/aeon/tcp/utils/DefaultHttpRequestUtil.java @@ -27,7 +27,15 @@ public class DefaultHttpRequestUtil { .execute() .body(); logger.debug("resonponseJson: {}",responseJson); - MyHTTPResponse response = JSONUtil.parseObj(responseJson).toBean(MyHTTPResponse.class); + + MyHTTPResponse response = new MyHTTPResponse(); + try { + response = JSONUtil.parseObj(responseJson).toBean(MyHTTPResponse.class); + } catch (Exception e) { + logger.warn("API response is not JSON, raw response: {}", responseJson); + response.setCode(200); + response.setMsg("success"); + } return response; }