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

8273961: jdk/nio/zipfs/ZipFSTester.java fails if file path contains '+' character #5574

Closed
wants to merge 1 commit into from

Conversation

1996scarlet
Copy link
Contributor

@1996scarlet 1996scarlet commented Sep 18, 2021

Add the pre-processing to replace "+" by "%2b" which avoids URLDecoder.decoder changing the path unexpectedly.

Please review this change. Thanks!


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8273961: jdk/nio/zipfs/ZipFSTester.java fails if file path contains '+' character

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5574/head:pull/5574
$ git checkout pull/5574

Update a local copy of the PR:
$ git checkout pull/5574
$ git pull https://git.openjdk.java.net/jdk pull/5574/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5574

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5574.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 18, 2021

👋 Welcome back 1996scarlet! 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 Sep 18, 2021
@openjdk
Copy link

openjdk bot commented Sep 18, 2021

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

  • nio

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 nio nio-dev@openjdk.org label Sep 18, 2021
@mlbridge
Copy link

mlbridge bot commented Sep 18, 2021

Webrevs

@@ -686,10 +686,11 @@ static void test8131067() throws Exception {
private static FileSystem newZipFileSystem(Path path, Map<String, ?> env)
throws Exception
{
var plusReplacedUri = path.toUri().toString().replace("+", "%2b");
Copy link
Contributor

@LanceAndersen LanceAndersen Sep 20, 2021

Choose a reason for hiding this comment

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

Thank you for your proposed patch.

The path described in the bug is a bit unusual and not something we typically expect (or have seen).

Please add a comment describing the purpose(maybe include a trivial example) of this change to make it more readily apparent to future maintainers.

Not sure I am enamored with the name of the variable plusReplacedUri. Perhaps consider an alternative name.

Copy link
Contributor Author

@1996scarlet 1996scarlet Sep 20, 2021

Choose a reason for hiding this comment

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

Thanks. It is a good idea to comment more information for maintainers.

BTW, this bug is caused by the newZipFileSystem method, which assert its parameter Path path is utf-8 encoded.
However, the path would not be encoded in most cases.
So the URLDecoder.decode(path.toUri().toString(), "utf8") at line 692 may cause unexpected results,

Maybe just remove the utf-8 decode logic is a valid option. What do you think?

Copy link
Contributor

@LanceAndersen LanceAndersen Sep 20, 2021

Choose a reason for hiding this comment

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

We should leave it as is for now as it does test newFileSystem via a URI which is also supported.

Certainly it could be updated at a later date when replacement is added(or at least more coverage) to exercise Zip FS, newFileSystem via URI.

@1996scarlet
Copy link
Contributor Author

1996scarlet commented Sep 21, 2021

Please reexamine this change. Thanks!

@1996scarlet 1996scarlet changed the title 8273961: [testbug] jdk/nio/zipfs/ZipFSTester.java fails if the path has plus character 8273961: jdk/nio/zipfs/ZipFSTester.java fails if file path contains '+' character Sep 21, 2021
// Use URLDecoder (for test only) to remove the double escaped space
// character
return FileSystems.newFileSystem(
new URI("jar", URLDecoder.decode(path.toUri().toString(), "utf8"),
new URI("jar", URLDecoder.decode(encoded, "utf8"),
Copy link
Contributor

@RealCLanger RealCLanger Sep 21, 2021

Choose a reason for hiding this comment

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

instead of using local variable encoded, I would just add the call to .replace("+", "%2b") inline.

The comments look good, I would suggest to put them between line 702/703.

Copy link
Contributor Author

@1996scarlet 1996scarlet Sep 21, 2021

Choose a reason for hiding this comment

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

Done. A new patch has been uploaded.

@openjdk
Copy link

openjdk bot commented Sep 21, 2021

⚠️ @1996scarlet the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout JDK-8273961
$ git commit -c user.name='Preferred Full Name' --allow-empty -m 'Update full name'
$ git push

@openjdk
Copy link

openjdk bot commented Sep 21, 2021

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

8273961: jdk/nio/zipfs/ZipFSTester.java fails if file path contains '+' character

Reviewed-by: clanger, lancea

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

  • a72c8aa: 8273921: Refactor NSK/JDI tests to create thread using factory
  • 161fdb4: 8273935: (zipfs) Files.getFileAttributeView() throws UOE instead of returning null when view not supported
  • 0fc47e9: 8266666: Implementation for snippets
  • 6d91a3e: 8269039: Disable SHA-1 Signed JARs
  • 42d5d2a: 8274056: JavaAccessibilityUtilities leaks JNI objects
  • 57df0db: 8270873: JFR: Catch DirectoryIteratorException when scanning for .jfr files
  • 111d5e1: 8273915: Create 'nosafepoint' rank
  • 7acec3f: 8236505: Mark jdk/editpad/EditPadTest.java as @headful
  • afd218d: 8274053: [BACKOUT] JDK-8270842: G1: Only young regions need to redirty outside references in remset.
  • a5108a6: 8273646: Add openssl from path variable also in to Default System Openssl Path in OpensslArtifactFetcher
  • ... and 31 more: https://git.openjdk.java.net/jdk/compare/bb9d142759ece7665329b124a8ea0b16049b024a...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 (@RealCLanger, @LanceAndersen) 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 Sep 21, 2021
@1996scarlet
Copy link
Contributor Author

1996scarlet commented Sep 22, 2021

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Sep 22, 2021
@openjdk
Copy link

openjdk bot commented Sep 22, 2021

@1996scarlet
Your change (at version be7c1fd) is now ready to be sponsored by a Committer.

@LanceAndersen
Copy link
Contributor

LanceAndersen commented Sep 22, 2021

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 22, 2021

Going to push as commit 7f78803.
Since your change was applied there have been 49 commits pushed to the master branch:

  • 51085b5: 8274054: Add custom enqueue calls during reference processing
  • c77ebe8: 8274060: C2: Incorrect computation after JDK-8273454
  • d9872ba: 8273590: Move helper classes in G1 post evacuation sub tasks to cpp files
  • 688b3fe: 8274070: Rectify problemlist platform for failing test on macos12
  • eeaf43b: 8274114: ProblemList serviceability/sa/TestJhsdbJstackMixed.java on linux-aarch64 in -Xcomp mode
  • 517405e: 8273965: some testlibrary_tests/ir_framework tests fail when c1 disabled
  • 11cddd3: 8272114: Unused _last_state in osThread_windows
  • cbe57e8: 8273684: Replace usages of java.util.Stack with ArrayDeque
  • a72c8aa: 8273921: Refactor NSK/JDI tests to create thread using factory
  • 161fdb4: 8273935: (zipfs) Files.getFileAttributeView() throws UOE instead of returning null when view not supported
  • ... and 39 more: https://git.openjdk.java.net/jdk/compare/bb9d142759ece7665329b124a8ea0b16049b024a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Sep 22, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and 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 Sep 22, 2021
@openjdk
Copy link

openjdk bot commented Sep 22, 2021

@LanceAndersen @1996scarlet Pushed as commit 7f78803.

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

@1996scarlet 1996scarlet deleted the JDK-8273961 branch Sep 23, 2021
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 nio nio-dev@openjdk.org
3 participants