Skip to content

8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body#11486

Closed
Karm wants to merge 3 commits intoopenjdk:masterfrom
Karm:aid-backporting-test-JDK-8245245
Closed

8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body#11486
Karm wants to merge 3 commits intoopenjdk:masterfrom
Karm:aid-backporting-test-JDK-8245245

Conversation

@Karm
Copy link
Contributor

@Karm Karm commented Dec 2, 2022

According to rfc6455, the close frame MAY contain a body, i.e. it is considered optional. It seems that the contemporary JDK HEAD (tip) does populate the body and thus enables HandshakeUrlEncodingTest.java to parse its contents. On the contrary, JDK 11 does not populate the body in the same case. I would like to backport JDK-8245245 all the way to JDK 11, so I would like to change the behavior of this test so as it works across JDK versions.


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-8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11486/head:pull/11486
$ git checkout pull/11486

Update a local copy of the PR:
$ git checkout pull/11486
$ git pull https://git.openjdk.org/jdk pull/11486/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11486

View PR using the GUI difftool:
$ git pr show -t 11486

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11486.diff

According to [rfc6455](https://www.rfc-editor.org/rfc/rfc6455.html#section-5.5.1), the close frame MAY contain a body,
i.e. it is considered [optional](https://www.rfc-editor.org/rfc/rfc2119#section-5).
It seems that the contemporary JDK HEAD (tip) does populate the body and thus enables `HandshakeUrlEncodingTest.java`
to parse its contents. On the contrary, JDK 11 does not populate the body in the same case.
I would like to backport JDK-8245245 all the way to JDK 11, so I would like to change the behavior of this test
so as it works across JDK versions.
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 2, 2022

👋 Welcome back Karm! 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
Copy link

openjdk bot commented Dec 2, 2022

@Karm 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.

@jaikiran
Copy link
Member

jaikiran commented Dec 5, 2022

Hello @Karm,

According to rfc6455, the close frame MAY contain a body, i.e. it is considered optional. It seems that the contemporary JDK HEAD (tip) does populate the body and thus enables HandshakeUrlEncodingTest.java to parse its contents. On the contrary, JDK 11 does not populate the body in the same case. I would like to backport JDK-8245245 all the way to JDK 11, so I would like to change the behavior of this test so as it works across JDK versions.

I believe the right thing to do here, to help with the backport of this test, is to also backport the actual change/fix which populates the HttpResponse body. I think that fix was done as part of https://bugs.openjdk.org/browse/JDK-8240666. So backporting that fix to JDK 11 should allow you to backport even this test case to JDK 11 without any changes to this test case.

@jerboaa
Copy link
Contributor

jerboaa commented Dec 5, 2022

Hello @Karm,

According to rfc6455, the close frame MAY contain a body, i.e. it is considered optional. It seems that the contemporary JDK HEAD (tip) does populate the body and thus enables HandshakeUrlEncodingTest.java to parse its contents. On the contrary, JDK 11 does not populate the body in the same case. I would like to backport JDK-8245245 all the way to JDK 11, so I would like to change the behavior of this test so as it works across JDK versions.

I believe the right thing to do here, to help with the backport of this test, is to also backport the actual change/fix which populates the HttpResponse body. I think that fix was done as part of https://bugs.openjdk.org/browse/JDK-8240666. So backporting that fix to JDK 11 should allow you to backport even this test case to JDK 11 without any changes to this test case.

Maybe. On the other hand, adding the response to the body of a websocket request is a behaviour change, which I find questionable as to being "the right thing to do", considering we are trying to solve an encoding bug in JDK 11 in a stable release. A bug fix shouldn't have a behaviour changing enhancement as a dependency if at all possible. Would this patch not be acceptable as is? It only encodes what the RFC states (allowing for empty body responses). Would the patch be more amenable if it were add additional body assertions iff the body is present?

@jaikiran
Copy link
Member

jaikiran commented Dec 6, 2022

Hello Severin,

I believe the right thing to do here, to help with the backport of this test, is to also backport the actual change/fix which populates the HttpResponse body. I think that fix was done as part of https://bugs.openjdk.org/browse/JDK-8240666. So backporting that fix to JDK 11 should allow you to backport even this test case to JDK 11 without any changes to this test case.

Maybe. On the other hand, adding the response to the body of a websocket request is a behaviour change, which I find questionable as to being "the right thing to do", considering we are trying to solve an encoding bug in JDK 11 in a stable release.

I see what you mean. In that case I think the backport process allows for the test to be updated in a way that it verifies (and passes) the actual bug fix i.e. you could do what you are proposing here, in the backport patch against the JDK 11 backport itself. My understanding is that the mainline isn't expected to take in such changes since the mainline isn't expected to be JDK version agnostic.

Having said that I think someone who's more aware of these processes will be able to provide a definitive answer. So I would recommend bringing this up in the net-dev mailing list https://mail.openjdk.org/mailman/listinfo/net-dev (this current PR hasn't triggered the official review process because of which the conversation here hasn't been copied over to the mailing list by the bots).

@jerboaa
Copy link
Contributor

jerboaa commented Dec 12, 2022

@Karm I've created https://bugs.openjdk.org/browse/JDK-8298588 for this test update. Please change the PR title to 8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body so that the bots recognize the bug.

@Karm Karm changed the title WebSockets: Makes HandshakeUrlEncodingTest JDK version agnostic 8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body Dec 13, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 13, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 13, 2022

Webrevs

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.

Checking the response URI is good but for the mainline I'd advise to check both the response URI and the body. It's fine to not check the response body on the update releases where JDK-8240666 is not present.

Whether you want to backport JDK-8240666 or not is an independent and unrelated decision - IMO.

@Karm
Copy link
Contributor Author

Karm commented Dec 13, 2022

Checking the response URI is good but for the mainline I'd advise to check both the response URI and the body. It's fine to not check the response body on the update releases where JDK-8240666 is not present.

Whether you want to backport JDK-8240666 or not is an independent and unrelated decision - IMO.

Thank you for the comment @dfuch

My objective is to have JDK-8245245 fixed in JDK 11.

I cannot do that cleanly because if I just took the original patch unchanged, HandshakeUrlEncodingTest would start to fail as it depends on JDK-8240666.

I was advised that is it not the best practice to alter something, i.e. HandshakeUrlEncodingTest, just in JDK 11 without doing it on the tip (mainline) first.

I don't think it's justifiable to backport JDK-8240666 solely to be able to cleanly backport JDK-8245245 as those two issues are only superficially related as I see it.

Could you help me put this in the context of our commentary on openjdk/jdk11u-dev#1558 (comment) and to plot a course of action that would be suitable, please?

@jerboaa
Copy link
Contributor

jerboaa commented Dec 13, 2022

@Karm Have you considered my suggestion from earlier? Would the patch be more amenable if it were to add additional body assertions iff the body is present? Perhaps that would be a middle ground to agree on?

@Karm
Copy link
Contributor Author

Karm commented Dec 13, 2022

@Karm Have you considered my suggestion from earlier? Would the patch be more amenable if it were to add additional body assertions iff the body is present? Perhaps that would be a middle ground to agree on?

I missed that in the comments. It makes perfect sense to me. I'll amend the patch this way.

Comment on lines 126 to 127
Copy link
Member

@dfuch dfuch Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of the mainline there MUST be a body - otherwise that is a bug in the implementation.
I believe the mainline test should therefore asserts that the body is present and equals to what it expects.

There is no requirement that a test in the mainline be the same than in previous releases, especially when the mainline test makes use of a functionality that is not present in those releases.

It should be perfectly fine to have the mainline test checks two things, and the update release test only one thing, because the second thing is not implemented in the update release.

If you modify the mainline test to simply add a check to assert that the response URI is what the text expects, then the diff between the update release test (that only check the response URI) and the mainline test after your fix (that checks both the response URI and the body) should naturally show that the mainline test has one additional test compared to the update release test - which is making use of a functionality only available in the mainline.

I would even suggest to modify the handler in the update release to not write anything into the response body since the body is discarded by the client implementation in that release.

The reason I'm a bit insistent on keeping the check on the body string is that it's the only thing that can reliably assert that the server has received the correct URI. Conceptually, the URI in the HttpResponse could have be composed by the client implementation itself. Writing the URI in the response body was a convenient way to check what the server had actually received.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @dfuch for the comment.

In the case of the mainline there MUST be a body - otherwise that is a bug in the implementation. I believe the mainline test should therefore asserts that the body is present and equals to what it expects.

I can see your point and I changed the test in my latest commit. The reason for my original approach for omitting it and for the subsequent step of checking for body presence was that the behavior of not/dropping body has its own test in WSHandshakeExceptionTest.java.

There is no requirement that a test in the mainline be the same than in previous releases, especially when the mainline test makes use of a functionality that is not present in those releases.

I see. I might got confused by comments on the jdk11u-dev thread:

The thing to do is use the buggy code from the original commit in this backport, 
fix the problem in tip, then backport that fix to 19u, 17u, and 11u.

It should be perfectly fine to have the mainline test checks two things, and the update release test only one thing, because the second thing is not implemented in the update release.

If you modify the mainline test to simply add a check to assert that the response URI is what the text expects, then the diff between the update release test (that only check the response URI) and the mainline test after your fix (that checks both the response URI and the body) should naturally show that the mainline test has one additional test compared to the update release test - which is making use of a functionality only available in the mainline.

I would even suggest to modify the handler in the update release to not write anything into the response body since the body is discarded by the client implementation in that release.

The diff between the test in this PR (tip, mailine) and the one in JDK 11 one pull/1558 is https://editor.mergely.com/dOyW1m6w/ .

The reason I'm a bit insistent on keeping the check on the body string is that it's the only thing that can reliably assert that the server has received the correct URI. Conceptually, the URI in the HttpResponse could have be composed by the client implementation itself. Writing the URI in the response body was a convenient way to check what the server had actually received.

I am glad you are providing feedback.

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 good to me! Thanks for improving this test. Please double check it still passes before integrating :-)

@openjdk
Copy link

openjdk bot commented Dec 15, 2022

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

8298588: WebSockets: HandshakeUrlEncodingTest unnecessarily depends on a response body

Reviewed-by: dfuchs

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 222 new commits pushed to the master branch:

  • 226e579: 8298088: RISC-V: Make Address a discriminated union internally
  • fa322e4: 8298709: Fix typos in src/java.desktop/ and various test classes of client component
  • e41686b: 8298710: Fix typos in test/jdk/sun/security/tools/jarsigner/
  • a336461: 8298081: DiagnoseSyncOnValueBasedClasses doesn't report useful information for virtual threads
  • 2bb727c: 8290899: java/lang/String/StringRepeat.java test requests too much heap on windows x86
  • 5412439: 8298187: (fs) BsdFileAttributeViews::setTimes does not support lastAccessTime on HFS+
  • 3cdbd87: 8298241: Replace C-style casts with JavaThread::cast
  • 10737e1: 8298468: Clean up class_loader parameters
  • 4b313b5: 8297798: Timeout with DTLSOverDatagram test template
  • ae8988e: 8297912: HotSpot Style Guide should permit alignas (Second Proposal Attempt)
  • ... and 212 more: https://git.openjdk.org/jdk/compare/6065696e5df2cde8c313083217ead3417d04c365...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dfuch) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 15, 2022
@Karm
Copy link
Contributor Author

Karm commented Dec 16, 2022

@dfuch

This looks good to me! Thanks for improving this test. Please double check it still passes before integrating :-)

It Works On My Machine ™️

@Karm
Copy link
Contributor Author

Karm commented Dec 16, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 16, 2022
@openjdk
Copy link

openjdk bot commented Dec 16, 2022

@Karm
Your change (at version 5b6c78b) is now ready to be sponsored by a Committer.

@jaikiran
Copy link
Member

I've run these changes against our internal CI systems and the tests went fine.

@jaikiran
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 16, 2022

Going to push as commit 909d0cb.
Since your change was applied there have been 222 commits pushed to the master branch:

  • 226e579: 8298088: RISC-V: Make Address a discriminated union internally
  • fa322e4: 8298709: Fix typos in src/java.desktop/ and various test classes of client component
  • e41686b: 8298710: Fix typos in test/jdk/sun/security/tools/jarsigner/
  • a336461: 8298081: DiagnoseSyncOnValueBasedClasses doesn't report useful information for virtual threads
  • 2bb727c: 8290899: java/lang/String/StringRepeat.java test requests too much heap on windows x86
  • 5412439: 8298187: (fs) BsdFileAttributeViews::setTimes does not support lastAccessTime on HFS+
  • 3cdbd87: 8298241: Replace C-style casts with JavaThread::cast
  • 10737e1: 8298468: Clean up class_loader parameters
  • 4b313b5: 8297798: Timeout with DTLSOverDatagram test template
  • ae8988e: 8297912: HotSpot Style Guide should permit alignas (Second Proposal Attempt)
  • ... and 212 more: https://git.openjdk.org/jdk/compare/6065696e5df2cde8c313083217ead3417d04c365...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 16, 2022

@jaikiran @Karm Pushed as commit 909d0cb.

💡 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.

4 participants

Comments