Cache evection of HTTP Client lead to not closed HttpClients
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 32/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
- 领域
- networking
调研方向
从链接的缓存构造处的 DefaultApacheHttpClient5Cache.java 开始,并查看 issue 755 中的讨论。跟踪池化的 CloseableHttpClients 在长时间运行或异步操作期间是如何创建、缓存、驱逐和使用的;完成标准是,被驱逐的客户端能够关闭,同时不中断仍在使用的客户端。
由索引模型根据 Issue 内容生成。
描述
Describe the Bug
The current implementation of caching and evicting an HTTP Client lead to not closed HttpClients.
Technically the HttpClients are CloseableHttpClient and should / need(specifically for pooled connections) to be closed after usage.
(See also this discussion)
In the current code-base, when a HttpClient with a PoolingHttpClientConnectionManager is created, it's not cleaned up properly on eviction.
The following workaround does not work in all cases:
cache = Caffeine.newBuilder().expireAfterAccess(duration, unit).ticker(ticker).evictionListener((key, value, cause) -> {
if (value instanceof CloseableHttpClient closeableHttpClient) {
try {
closeableHttpClient.close();
} catch (final Exception e) {
log.warn("Failed to close HttpClient. Ignoring the exception and continue.", e);
}
}
}).build();
There are two basic scenarios:
- The client was created and is no longer in use and the eviction time triggers the cleanup. ✅
- The client was created and in still in use (long running operation, async operation, ...) and the eviction time triggers the cleanup. Then the
evictionListenerwould kill the connection underneath. ❌
Steps to Reproduce
Code review.
Expected Behavior
Proper closing of HttpClients.
Screenshots
No response
Used Versions
Current state in main.
Code Examples
// Your code here
Stack Trace
No response
Log File
Log file
...Affected Development Phase
Development
Impact
No Impact
Timeline
No response
- 主要语言
- Java
- 星标
- 41
- 派生
- 33
- 平均合并
- 1 天 57 分钟
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SAP/cloud-sdk-java 的其他 Issue
-
bug
难度 4/5 3-5 天 新手友好度 48/100
SAP/cloud-sdk-java#1291 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
SAP/cloud-sdk-java#1290 · 2 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 35/100
SAP/cloud-sdk-java#1289 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
SAP/cloud-sdk-java#1280 · 1 条评论 ·
维护者通常 1 天内回复
-
Newly introduced `CsrfTokenInterceptor` is producing large amount of warning logs可能已有人在做 @ricardosrib 于 17 天前认领。 未关闭bug
SAP/cloud-sdk-java#1270 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 SAP/cloud-sdk-java 的全部 Issue
相似的 Issue
-
1.0.0-rc2
难度 2/5 1-3 小时 新手友好度 68/100
wso2/dpdp-accelerator#377 ·
维护者通常 1 天内回复
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 2 天内回复
-
(primitive-collections-base) Use `NumberInput` to parse numeric map keys, as `jackson-databind` does未关闭
难度 2/5 1-3 小时 新手友好度 78/100
FasterXML/jackson-datatypes-collections#270 ·
维护者通常 1 天内回复
-
type/bug
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复