Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2320#discussion_r73333859
  
    --- Diff: 
flink-yarn/src/main/java/org/apache/flink/yarn/cli/FlinkYarnSessionCli.java ---
    @@ -260,8 +263,15 @@ public AbstractYarnClusterDescriptor 
createDescriptor(String defaultApplicationN
                } else {
                        LOG.info("No path for the flink jar passed. Using the 
location of "
                                + yarnClusterDescriptor.getClass() + " to 
locate the jar");
    -                   localJarPath = new Path("file://" +
    -                           
yarnClusterDescriptor.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
    +                   String encodedJarPath =
    +                           
yarnClusterDescriptor.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
    +                   try {
    +                           // we have to decode the url encoded parts of 
the path
    +                           localJarPath = new Path("file://" + 
URLDecoder.decode(encodedJarPath, Charset.defaultCharset().name()));
    --- End diff --
    
    I think manually coding the `file:// + path` URIs have cross-platform 
issues.
    
    For File URIs, I found it to be best to go with 
    ```java
    new File(string).toURI()
    ```
    or in that specific case:
    ```java
    localJarPath = new Path(new File(URLDecoder.decode(encodedJarPath, 
Charset.defaultCharset().name())).toURI());
    or
    localJarPath = new Path(new URI("file", null, 
URLDecoder.decode(encodedJarPath, Charset.defaultCharset().name()), null));
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to