[ 
https://issues.apache.org/jira/browse/CALCITE-2495?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16595614#comment-16595614
 ] 

Vladimir Sitnikov commented on CALCITE-2495:
--------------------------------------------

Here goes Windows + Java 11:

{code:java}jshell> new File("/foo")
$4 ==> \foo

jshell> new File("/foo").isAbsolute()
$5 ==> false

jshell> new File("/foo").getAbsolutePath()
$6 ==> "C:\\foo"

jshell> new URL("file:c:/file.txt").toURI().isOpaque()
$9 ==> true

jshell> new URL("file:c:/file.txt").toURI().getRawSchemeSpecificPart()
$11 ==> "c:/file.txt"

jshell> new File(new 
URL("file:c:/file.txt").toURI().getRawSchemeSpecificPart()).isAbsolute()
$12 ==> true

jshell> new File(new URL("file:c:/file.txt").toURI())
|  Exception java.lang.IllegalArgumentException: URI is not hierarchical
|        at File.<init> (File.java:418)
|        at (#13:1)
{code}

In other words:
1) {{URI()#isOpaque()}} does not mean file path is "relative". It could be 
absolute path like {{c:/test.txt}} for Windows
2) {{new File("/foo")}} is relative for Windows. The missing part is drive 
letter.

PS. I would like to throw {{UnsupportedOperationException}} from 
{{Source#append(Source)}} since the implementation gets hairy, and cost-benefit 
is not that clear.

> Rework URL->File conversion in tests
> ------------------------------------
>
>                 Key: CALCITE-2495
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2495
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>            Priority: Major
>
> {{URL.getPath()}} produces %20 when path contains spaces.
> I suggest to rework all the uses of {{getResource()...}} to use 
> {{Sources.of(URL)}} so there's single -point of failure- way to convert URL 
> to File.
> This resolves Apache CI which happens to have a space in folder name.
> For the record:
> 1) {{URL.getPath()}} produces %20, so it is added to forbidden signatures
> 2) {{Paths.get(url.toURI()).toFile()}} almost works, however it fails with 
> URL is not hierarchical for {{new URL("file:test.java")}}
> 3) {{new File(URL.toURI()}} is worse than #2
> 4) {{URLDecoder}} must not be used to decode %20, since it will convert {{+}} 
> to spaces as well, thus it will corrupt {{test.c++}}
> 5) It looks like {{url.toURI().getSchemeSpecificPart())}} properly handles 
> "opaque" URIs (which are relative {{file:test.java}} kind of URLs)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to