-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8276798: HttpURLConnection sends invalid HTTP request #9038
Conversation
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
Additionally, the reproducer attached to the JBS issue has been run locally. The test fails regularly without this change and hasn't failed even once after this change. |
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.
This looks reasonable to me but I would like to get a second opinion. @Michael-Mc-Mahon ?
@jaikiran This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 241 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
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.
LGTM. Probably need to add noreg-hard
label to bug.
Done. |
/integrate |
Going to push as commit 50c37f5.
Your commit was automatically rebased without conflicts. |
Can I please get a review of this change which proposes to fix https://bugs.openjdk.java.net/browse/JDK-8276798?
sun.net.www.protocol.http.HttpURLConnection
has a (private)writeRequests
method. This method is responsible for creating the standard HTTP request headers (include the request line) and then writing it out to theOutputStream
which communicates with the HTTP server. While writing out these request headers, if there's an IOException, thenHttpURLConnection
marks afailedOnce
flag totrue
and attempts to write these again afresh (after creating new connection to the server). This re-attempt is done just once.As noted in the linked JBS issue, specifically this comment https://bugs.openjdk.java.net/browse/JDK-8276798?focusedCommentId=14500074&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14500074, there's a specific case where creating and writing out these request headers ends up skipping the request line, which causes the server to respond back with a "Bad Request" response code.
The commit in this PR removes the use of
failedOnce
flag that was being used to decide whether or not to write the request line. The existing code doesn't have any specific comments on why this check was there in first place, nor does the commit history show anything about this check. However, reading through that code, my guess is that, it was there to avoid writing the request line twice when the samerequests
object gets reused during the re-attempt. I think a better check would be the see if therequests
already has the request line and if not add it afresh.While in this code, I also removed the check where the
failedOnce
flag was being used to check if theConnection: Keep-Alive
/Proxy-Connection: Keep-alive
header needs to be set. This part of the code already has a call tosetIfNotSet
, so I don't think we need thefailedOnce
check here.tier1, tier2 and tier3 tests have passed without issues. However, given the nature of this code, I'm not too confident that we have tests which can catch this issue (and adding one isn't easy), so I would like inputs on whether this change is good enough or whether it has the potential to cause any non-obvious regressions.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9038/head:pull/9038
$ git checkout pull/9038
Update a local copy of the PR:
$ git checkout pull/9038
$ git pull https://git.openjdk.org/jdk pull/9038/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9038
View PR using the GUI difftool:
$ git pr show -t 9038
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9038.diff