mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 15:37:28 +00:00
fix: PanBase WebClient 改为静态共享单例,修复每请求创建4个实例的资源泄漏
WebClient 是线程安全的,将 client/clientNoRedirects/clientDisableUA 改为 static 共享实例, 避免每次解析请求创建4个独立 WebClient(各含连接池)。 clientSession 仍保持实例级(管理 cookie,非线程安全)。 代理模式下仍创建独立 WebClient 实例。
This commit is contained in:
@@ -40,28 +40,34 @@ public abstract class PanBase implements IPanTool {
|
|||||||
protected Promise<String> promise = Promise.promise();
|
protected Promise<String> promise = Promise.promise();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http client
|
* 共享的 WebClient 实例(线程安全,避免每请求创建导致资源泄漏)
|
||||||
*/
|
*/
|
||||||
protected WebClient client = WebClient.create(WebClientVertxInit.get(),
|
private static final WebClient SHARED_CLIENT = WebClient.create(WebClientVertxInit.get(),
|
||||||
new WebClientOptions());
|
new WebClientOptions());
|
||||||
|
private static final WebClient SHARED_CLIENT_NO_REDIRECTS = WebClient.create(WebClientVertxInit.get(),
|
||||||
|
new WebClientOptions().setFollowRedirects(false));
|
||||||
|
private static final WebClient SHARED_CLIENT_DISABLE_UA = WebClient.create(WebClientVertxInit.get(),
|
||||||
|
new WebClientOptions().setUserAgentEnabled(false));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http client session (会话管理, 带cookie请求)
|
* Http client (默认使用共享实例,代理模式下使用独立实例)
|
||||||
|
*/
|
||||||
|
protected WebClient client = SHARED_CLIENT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Http client session (会话管理, 带cookie请求, 每实例独立)
|
||||||
*/
|
*/
|
||||||
protected WebClientSession clientSession = WebClientSession.create(client);
|
protected WebClientSession clientSession = WebClientSession.create(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http client 不自动跳转
|
* Http client 不自动跳转
|
||||||
*/
|
*/
|
||||||
protected WebClient clientNoRedirects = WebClient.create(WebClientVertxInit.get(),
|
protected WebClient clientNoRedirects = SHARED_CLIENT_NO_REDIRECTS;
|
||||||
new WebClientOptions().setFollowRedirects(false));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Http client disable UserAgent
|
* Http client disable UserAgent
|
||||||
*/
|
*/
|
||||||
protected WebClient clientDisableUA = WebClient.create(WebClientVertxInit.get()
|
protected WebClient clientDisableUA = SHARED_CLIENT_DISABLE_UA;
|
||||||
, new WebClientOptions().setUserAgentEnabled(false)
|
|
||||||
);
|
|
||||||
|
|
||||||
protected ShareLinkInfo shareLinkInfo;
|
protected ShareLinkInfo shareLinkInfo;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user