Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

jaikiran
Copy link
Member

@jaikiran jaikiran commented Jun 6, 2022

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 the OutputStream which communicates with the HTTP server. While writing out these request headers, if there's an IOException, then HttpURLConnection marks a failedOnce flag to true 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 same requests object gets reused during the re-attempt. I think a better check would be the see if the requests 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 the Connection: Keep-Alive/Proxy-Connection: Keep-alive header needs to be set. This part of the code already has a call to setIfNotSet, so I don't think we need the failedOnce 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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8276798: HttpURLConnection sends invalid HTTP request

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

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 6, 2022

👋 Welcome back jpai! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 6, 2022
@openjdk
Copy link

openjdk bot commented Jun 6, 2022

@jaikiran The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the net net-dev@openjdk.org label Jun 6, 2022
@mlbridge
Copy link

mlbridge bot commented Jun 6, 2022

Webrevs

@jaikiran
Copy link
Member Author

jaikiran commented Jun 8, 2022

tier1, tier2 and tier3 tests have passed without issues.

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.

Copy link
Member

@dfuch dfuch left a 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 ?

@openjdk
Copy link

openjdk bot commented Jun 8, 2022

@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:

8276798: HttpURLConnection sends invalid HTTP request

Reviewed-by: dfuchs, michaelm

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 master branch:

  • 270cf67: 8288752: Split thread implementation files
  • d51f4f4: 8287011: Improve container information
  • affbd72: 8288744: Remove tools/jlink/plugins/CompressorPluginTest.java from problemlist
  • 2bf5c9a: Merge
  • 70008da: 8287971: Throw exception for missing values in .jpackage.xml
  • d7b43af: 8288761: SegmentAllocator:allocate(long bytesSize) not throwing IAEx when bytesSize < 0
  • 834d92d: 8288754: GCC 12 fails to build zReferenceProcessor.cpp
  • 198cec9: 8286103: VThreadMonitorTest fails "assert(!current->cont_fastpath() || (current->cont_fastpath_thread_state() && !interpreted_native_or_deoptimized_on_stack(current))) failed"
  • 97200a7: 8278053: serviceability/jvmti/vthread/ContStackDepthTest/ContStackDepthTest.java failing in loom repo with Xcomp
  • 31d981e: 8288532: additional review changes for JDK-8286830
  • ... and 231 more: https://git.openjdk.org/jdk/compare/24fe8ad74cc481d18bed6896ca54a8d91c651d4a...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 8, 2022
Copy link
Member

@Michael-Mc-Mahon Michael-Mc-Mahon left a 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.

@jaikiran
Copy link
Member Author

Probably need to add noreg-hard label to bug.

Done.
Thank you Daniel and Michael for the reviews.

@jaikiran
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 22, 2022

Going to push as commit 50c37f5.
Since your change was applied there have been 241 commits pushed to the master branch:

  • 270cf67: 8288752: Split thread implementation files
  • d51f4f4: 8287011: Improve container information
  • affbd72: 8288744: Remove tools/jlink/plugins/CompressorPluginTest.java from problemlist
  • 2bf5c9a: Merge
  • 70008da: 8287971: Throw exception for missing values in .jpackage.xml
  • d7b43af: 8288761: SegmentAllocator:allocate(long bytesSize) not throwing IAEx when bytesSize < 0
  • 834d92d: 8288754: GCC 12 fails to build zReferenceProcessor.cpp
  • 198cec9: 8286103: VThreadMonitorTest fails "assert(!current->cont_fastpath() || (current->cont_fastpath_thread_state() && !interpreted_native_or_deoptimized_on_stack(current))) failed"
  • 97200a7: 8278053: serviceability/jvmti/vthread/ContStackDepthTest/ContStackDepthTest.java failing in loom repo with Xcomp
  • 31d981e: 8288532: additional review changes for JDK-8286830
  • ... and 231 more: https://git.openjdk.org/jdk/compare/24fe8ad74cc481d18bed6896ca54a8d91c651d4a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 22, 2022
@openjdk openjdk bot closed this Jun 22, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 22, 2022
@openjdk
Copy link

openjdk bot commented Jun 22, 2022

@jaikiran Pushed as commit 50c37f5.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated net net-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants