-
Notifications
You must be signed in to change notification settings - Fork 3.1k
test(sdk-java): close the connection on body-less fixture responses #10472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] R1-1: No committed test pins this fix's only behavioural line — the
Connection: closeheader set inside the newsendNoContenthelper. Nothing goes red if the header line is removed, and nothing enforces that future body-less fixture responses go through the helper (the consolidation is a convention, not an enforced one). If a later edit deletes the line — or a new 204/empty-stream handler is written with rawsendResponseHeaders(status, -1)— the Java 11 pool race this PR removes silently comes back: per the PR's own measurements the flake lands roughly once per twelve two-core class runs and intermittently in CI while Java 17/21 lanes stay green, so ordinary full-suite runs pass and the regression surfaces only as sporadicDetachOutcomeUnknownExceptionfailures on unrelated branches — the exact symptom this PR exists to end.Witness:
A small deterministic test can pin the mechanism: serve the fixture's body-less handler on an
HttpServerand assert thejava.net.http.HttpClientresponse carriesConnection: close— this is the probe-verified shape (it flips red/green exactly with the header line). The optional stronger variant is a Java-11-gated loop test of "body-less response, then a mutation request" in the shape of the pairing harness from the PR description.The new assertion test itself must go red when the
Connection: closeline is removed fromsendNoContent— please prove it with the mutation: remove the header line, run that test, confirm it goes red.中文说明
没有任何已提交的测试钉住本次修复唯一的行为改动——新
sendNoContent辅助方法里设置Connection: close响应头的那一行。如果这行被删掉,不会有任何测试变红;也没有任何机制强制未来新增的"无响应体"返回必须走这个辅助方法(目前的归并只是约定,并非强制)。一旦后续编辑删掉这行——或者有人用裸的sendResponseHeaders(status, -1)新写了一个 204/空事件流 handler——本 PR 消除的 Java 11 连接池竞态就会悄悄回来:按本 PR 自己的测量,该 flake 在双核下大约每十二次类级运行命中一次,在 CI 中间歇性出现,而 Java 17/21 lane 始终为绿——所以普通的全量测试会通过,回归只会以不相干分支上偶发的DetachOutcomeUnknownException失败形式浮现,而这正是本 PR 要终结的症状。验证证据(探针翻转):完整代码树上,响应头断言探针
Tests run: 1, Failures: 0(观察到Connection: close);删除该行响应头的突变树上,探针报AssertionFailedError: response carries a Connection header ==> expected: <true> but was: <false>,而已提交的完整DaemonSessionClientTest在 JDK 21 上仍为Tests run: 103, Failures: 0, Errors: 0 — BUILD SUCCESS——说明没有任何其他测试钉住这一行。一个小的确定性测试即可钉住该机制:把夹具的无响应体 handler 挂到一个
HttpServer上,断言java.net.http.HttpClient收到的响应携带Connection: close——这正是本次评审探针验证过的形态(它随该行响应头的存亡精确翻转)。可选的更强形态是按 PR 描述中配对工具的形状,写一个 Java 11 专属的"无响应体响应 + 随后一个 mutation 请求"循环测试。新增的断言测试本身必须在
sendNoContent中的Connection: close一行被移除后变红——请用突变验证:删掉该行响应头,运行该测试,确认它变红。— qwen3.8-max via Qwen Code /review (v0.22.3)