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

Sean Owen commented on SPARK-22585:
-----------------------------------

Hm, I think the issue is rather than the path needs to be encoded before 
becoming part of the URI. The URI 
{{file:/home/me/.coursier/cache/v1/https/artifactory.com%3A443/path/to.jar}} is 
not one that names your file; it's 
{{file:/home/me/.coursier/cache/v1/https/artifactory.com%253A443/path/to.jar}} 
(escaped %). That may be a workaround here.
{{/home/me/.coursier/cache/v1/https/artifactory.com%3A443/path/to.jar}} is 
however a valid and correct local path to the file, and that's what the 
argument is meant to be. So the code should do the encoding. I'm aware that 
there are a number of places that probably turn paths into URIs, so would be 
best to try to update all issues of this form. I think it's low-risk as URI 
encoding won't do anything for most paths, and where it does, it's probably 
essential.

> Url encoding of jar path expected?
> ----------------------------------
>
>                 Key: SPARK-22585
>                 URL: https://issues.apache.org/jira/browse/SPARK-22585
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.2.0
>            Reporter: Jakub Dubovsky
>
> I am calling {code}sparkContext.addJar{code} method with path to a local jar 
> I want to add. Example:
> {code}/home/me/.coursier/cache/v1/https/artifactory.com%3A443/path/to.jar{code}.
>  As a result I get an exception saying
> {code}
> Failed to add 
> /home/me/.coursier/cache/v1/https/artifactory.com%3A443/path/to.jar to Spark 
> environment. Stacktrace:
> java.io.FileNotFoundException: Jar 
> /home/me/.coursier/cache/v1/https/artifactory.com:443/path/to.jar not found
> {code}
> Important part to notice here is that colon character is url encoded in path 
> I want to use but exception is complaining about path in decoded form. This 
> is caused by this line of code from implementation ([see 
> here|https://github.com/apache/spark/blob/v2.2.0/core/src/main/scala/org/apache/spark/SparkContext.scala#L1833]):
> {code}
> case null | "file" => addJarFile(new File(uri.getPath))
> {code}
> It uses 
> [getPath|https://docs.oracle.com/javase/7/docs/api/java/net/URI.html#getPath()]
>  method of 
> [java.net.URI|https://docs.oracle.com/javase/7/docs/api/java/net/URI.html] 
> which url decodes the path. I believe method 
> [getRawPath|https://docs.oracle.com/javase/7/docs/api/java/net/URI.html#getRawPath()]
>  should be used here which keeps path string in original form.
> I tend to see this as a bug since I want to use my dependencies resolved from 
> artifactory with port directly. Is there some specific reason for this or can 
> we fix this?
> Thanks



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to