From 98d120bd0633e4e0717d584cae5514132a18516b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 18 十二月 2025 13:36:09 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/HttpHandler.java | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/HttpHandler.java b/src/main/java/com/zy/common/utils/HttpHandler.java
index 70adcc7..e90584e 100644
--- a/src/main/java/com/zy/common/utils/HttpHandler.java
+++ b/src/main/java/com/zy/common/utils/HttpHandler.java
@@ -51,8 +51,13 @@
}
}
Request request = headerBuilder.url(url).build();
- Response response = getClient(timeout, timeUnit).newCall(request).execute();
- return response.isSuccessful() ? response.body().string() : null;
+ OkHttpClient client = getClient(timeout, timeUnit);
+ Response response = client.newCall(request).execute();
+ String result = response.isSuccessful() ? response.body().string() : null;
+ response.close();
+ try { client.dispatcher().executorService().shutdown(); } catch (Exception ignore) {}
+ try { client.connectionPool().evictAll(); } catch (Exception ignore) {}
+ return result;
}
/**
@@ -84,10 +89,14 @@
request = builder.post(body).build();
}
- Call call = getClient(timeout, timeUnit).newCall(request);
+ OkHttpClient client = getClient(timeout, timeUnit);
+ Call call = client.newCall(request);
Response response = call.execute();
- return response.body().string();
-
+ String result = response.body().string();
+ response.close();
+ try { client.dispatcher().executorService().shutdown(); } catch (Exception ignore) {}
+ try { client.connectionPool().evictAll(); } catch (Exception ignore) {}
+ return result;
}
/**
--
Gitblit v1.9.1