|
|
@ -99,13 +99,19 @@ public class HttpUtils { |
|
|
HttpResponse<String> response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString()); |
|
|
HttpResponse<String> response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString()); |
|
|
return handleResponse(response); |
|
|
return handleResponse(response); |
|
|
} catch (java.net.http.HttpTimeoutException e) { |
|
|
} catch (java.net.http.HttpTimeoutException e) { |
|
|
// 超时异常特殊处理 - rqrq |
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
throw new RuntimeException("接口响应超时(60秒),请检查网络连接或者接口服务是否可用。 " ); |
|
|
throw new RuntimeException("接口响应超时(60秒),请检查网络连接或者接口服务是否可用。 " ); |
|
|
} catch (IOException | InterruptedException e) { |
|
|
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
|
|
throw new RuntimeException("POST 请求失败: " + e.getMessage(), e); |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
// IO 错误:不涉及中断 |
|
|
|
|
|
throw new RuntimeException("网络或IO错误: " + e.getMessage(), e); |
|
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
|
// 线程被中断:恢复中断状态,并抛出异常(或返回) |
|
|
|
|
|
Thread.currentThread().interrupt(); // ✅ 合理 |
|
|
|
|
|
throw new RuntimeException("请求被中断", e); |
|
|
} |
|
|
} |
|
|
|
|
|
// (IOException | InterruptedException e) { |
|
|
|
|
|
// Thread.currentThread().interrupt(); |
|
|
|
|
|
// throw new RuntimeException("POST 请求失败: " + e.getMessage(), e); |
|
|
|
|
|
// } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** 构建查询参数字符串 */ |
|
|
/** 构建查询参数字符串 */ |
|
|
|