You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-issues@hadoop.apache.org by "Todd Lipcon (JIRA)" <ji...@apache.org> on 2009/07/07 02:57:14 UTC

[jira] Created: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

JobConf.findContainingJar unescapes unnecessarily on Linux
----------------------------------------------------------

                 Key: MAPREDUCE-714
                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
             Project: Hadoop Map/Reduce
          Issue Type: Bug
            Reporter: Todd Lipcon


In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAPREDUCE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727883#action_12727883 ] 

Todd Lipcon commented on MAPREDUCE-714:
---------------------------------------

Here's a potential fix, which is really klugey. If no one objects to this I'll upload it as a real patch in the next couple of days:

{code}
diff --git a/src/mapred/org/apache/hadoop/mapred/JobConf.java b/src/mapred/org/apache/hadoop/mapred/JobConf.java
index 11be95a..4794eab 100644
--- a/src/mapred/org/apache/hadoop/mapred/JobConf.java
+++ b/src/mapred/org/apache/hadoop/mapred/JobConf.java
@@ -1452,6 +1452,13 @@ public class JobConf extends Configuration {
           if (toReturn.startsWith("file:")) {
             toReturn = toReturn.substring("file:".length());
           }
+          // URLDecoder is a misnamed class, since it actually decodes
+          // x-www-form-urlencoded MIME type rather than actual
+          // URL encoding (which the file path has). Therefore it would
+          // decode +s to ' 's which is incorrect (spaces are actually
+          // either unencoded or encoded as "%20"). Replace +s first, so
+          // that they are kept sacred during the decoding process.
+          toReturn = toReturn.replaceAll("\\+", "%2B");
           toReturn = URLDecoder.decode(toReturn, "UTF-8");
           return toReturn.replaceAll("!.*$", "");
         }
{code}

> JobConf.findContainingJar unescapes unnecessarily on Linux
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-714
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Todd Lipcon
>
> In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAPREDUCE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728801#action_12728801 ] 

Owen O'Malley commented on MAPREDUCE-714:
-----------------------------------------

Are there any other characters that need to be fixed? I'm worried that this is a point solution for one character rather than the right solution.

> JobConf.findContainingJar unescapes unnecessarily on Linux
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-714
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Todd Lipcon
>
> In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAPREDUCE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728804#action_12728804 ] 

Todd Lipcon commented on MAPREDUCE-714:
---------------------------------------

Owen: that's the only difference I know of that's mentioned in the spec: http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1

I spent about 4 hours trying to find a portable non-klugey fix. The trouble is that the behavior is different on Windows compared to Linux. On a Windows JVM, it encodes spaces as "%20" and +s as "%2B" and on Linux it does neither, best I can tell.

I definitely agree that this fix is not optimal, but I think '+' is the most common case for a "weird" character in a JAR name. In Debian and RPM packages, the non-alphanumeric characters allowed in version numbers are [+-~.:] and I think all of those should be fine after this patch.

> JobConf.findContainingJar unescapes unnecessarily on Linux
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-714
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Todd Lipcon
>
> In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

Posted by "Todd Lipcon (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAPREDUCE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727862#action_12727862 ] 

Todd Lipcon commented on MAPREDUCE-714:
---------------------------------------

I just confirmed this on Windows vs Linux. On Windows, the URL that you get back from ClassLoader.getResource has spaces encoded as "%20". On Linux it doesn't.

Anyone have a creative solution to deal with this? We'd like to have +s in our version numbers due to standards in RPM and Debian land, but this is blocking that.

> JobConf.findContainingJar unescapes unnecessarily on Linux
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-714
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Todd Lipcon
>
> In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MAPREDUCE-714) JobConf.findContainingJar unescapes unnecessarily on Linux

Posted by "Owen O'Malley (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MAPREDUCE-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728812#action_12728812 ] 

Owen O'Malley commented on MAPREDUCE-714:
-----------------------------------------

Of course, you could detect the operating system like Path does.

Look at the definition of Path.WINDOWS. Of course, we probably should make a method that checks that boolean...

That said, I'm ok with the quoting as long as it works on both operating systems. (I agree, it is kludgy, but...)

> JobConf.findContainingJar unescapes unnecessarily on Linux
> ----------------------------------------------------------
>
>                 Key: MAPREDUCE-714
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-714
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: Todd Lipcon
>
> In JobConf.findContainingJar, the path name is decoded using URLDecoder.decode(...). This was done by Doug in r381794 (commit msg "Un-escape containing jar's path, which is URL-encoded.  This fixes things primarily on Windows, where paths are likely to contain spaces.") Unfortunately, jar paths do not appear to be URL encoded on Linux. If you try to use "hadoop jar" on a jar with a "+" in it, this function decodes it to a space and then the job cannot be submitted.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.