JDK-8242258 : (jrtfs) Path::toUri throws AssertionError for malformed input
  • Type: Bug
  • Component: tools
  • Sub-Component: jlink
  • Affected Version: 14,15
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-04-03
  • Updated: 2021-03-12
  • Resolved: 2020-12-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b28Fixed
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
jrt FileSystem's Path.toUri() throws AssertionErrors for paths starting with "/modules" followed by a char sequence which URI considers an invalid IPv6 address.

The behavior before JDK 13 might be different due to JDK-8224946, there the path must not have the "/modules" prefix, but instead directly have the invalid IPv6 address.


---------- BEGIN SOURCE ----------
try {
    FileSystems.getFileSystem(URI.create("jrt:/")).getPath("/modules/[").toUri();
    throw new RuntimeException("Expected AssertionError");
}
catch (AssertionError expected) {
    expected.printStackTrace();
}
---------- END SOURCE ----------


Comments
The follow-up report (JDK-8259952) is still unresolved as well.
12-03-2021

Requested the submitter to verify the fix with the latest version of JDK at https://jdk.java.net/16/
10-03-2021

The results from the submitter: it appears this by accident additionally fixes another bug where converting a path containing a question mark ('?') to URI and then back to Path would throw an exception, e.g. `"/modules/test?a"`. However, the commit also introduces a new bug where characters whose code point is > 127 are not properly encoded, e.g.: ``` FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jrt:/")); String originalPath = "/modules/\u00E4"; Path path = fileSystem.getPath(originalPath); URI uri = path.toUri(); String reconverted = fileSystem.provider().getPath(uri).toString(); System.out.println("Result: " + reconverted); System.out.println("Are paths equal: " + reconverted.equals(originalPath));
15-01-2021

Requested the submitter verify the fix with latest version of JDK 16.
13-01-2021

Changeset: d2b66196 Author: Athijegannathan Sundararajan <sundar@openjdk.org> Date: 2020-12-08 09:38:38 +0000 URL: https://git.openjdk.java.net/jdk/commit/d2b66196
08-12-2020

Testing a fix for this issue.
04-12-2020

UriPath will need to do escaping to avoid throwing an exception here. The resulting URI will be useless of course.
07-04-2020

The observation on Windows 10: JDK 14: Fail. ILW=MML=P4
06-04-2020