RFR: 8273961: [testbug] jdk/nio/zipfs/ZipFSTester.java fails if the path has plus character

Remilia Scarlet github.com+22913521+1996scarlet at openjdk.java.net
Mon Sep 20 14:12:03 UTC 2021


On Mon, 20 Sep 2021 10:09:39 GMT, Lance Andersen <lancea at openjdk.org> wrote:

>> Add the pre-processing to replace "+" by "%2b" which avoids `URLDecoder.decoder` changing the path unexpectedly.
>> 
>> Please review this change. Thanks!
>
> test/jdk/jdk/nio/zipfs/ZipFSTester.java line 689:
> 
>> 687:         throws Exception
>> 688:     {
>> 689:         var plusReplacedUri = path.toUri().toString().replace("+", "%2b");
> 
> 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.

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?

-------------

PR: https://git.openjdk.java.net/jdk/pull/5574


More information about the nio-dev mailing list