优化:区分 HTTP 错误,返回明确原因#752
Merged
klboke merged 3 commits intokekingcn:masterfrom May 9, 2026
Merged
Conversation
klboke
requested changes
May 8, 2026
Contributor
klboke
left a comment
There was a problem hiding this comment.
发现一个需要修改的 blocker:
server/src/main/java/cn/keking/web/controller/OnlinePreviewController.java:197在/getCorsFile的 HTTP 分支里用 try-with-resources 关闭了HttpRequestUtils.createConfiguredHttpClient()返回的CloseableHttpClient。但这个方法返回的是HttpRequestUtils内部缓存的共享 client,而不是一次性 client。这样一次/getCorsFile请求结束后会把缓存 client 关闭,后续 PDF/image/office 等依赖/getCorsFile代理读取的预览请求可能复用到已关闭的 client,从而失败。建议不要在这里关闭该 client,继续让HttpRequestUtils.shutdown()负责缓存 client 生命周期。
验证:mvn -q -pl server -DskipTests compile 通过。
建议补一条两个连续 /getCorsFile HTTP 请求的回归测试,覆盖这个共享 client 生命周期问题。
Contributor
Author
|
已经 修复了 |
klboke
approved these changes
May 9, 2026
Contributor
klboke
left a comment
There was a problem hiding this comment.
复查了最新 head,之前指出的 blocker 已修复:/getCorsFile 现在不再关闭 HttpRequestUtils.createConfiguredHttpClient() 返回的共享缓存 client,client 生命周期仍由 HttpRequestUtils.shutdown() 统一处理。
验证:mvn -q -pl server -DskipTests compile 通过。
非阻塞建议:
- 后续可以补一条两个连续
/getCorsFileHTTP 请求的回归测试,防止共享 client 生命周期问题回归。 - 新增的
HttpClientLifecycle里建议用 logger 替代System.out.println,并补文件末尾换行。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1、修复 MIME 类型校验失败后仍返回成功
2、增强异常处理,区分 HTTP 客户端异常
3、完善未知异常的兜底处理