Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-15326

ClassUtil usage of URLDecode precludes '+' in jar path

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: util
    • Labels:
      None
    • Environment:

      Java: 1.8.0_111
      hadoop: 2.5.2

      OSX: 10.13.3

      Description

      Problem

      ClassUtil utilizes URLDecoder to decode the path to the jar containing the provided Class. However, as noted here: https://bugs.openjdk.java.net/browse/JDK-8179507?focusedCommentId=14074306&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14074306 URLDecoder should only be used for HTML forms, because it causes issues with plus signs (and other characters).

      I can demonstrate the issue in the below Spock Specification:

      import spock.lang.Specification
      
      class Testy extends Specification{
          def "testy"(){
              setup:
              URL url = new URL("jar:file:/path/to/some+dir/hadoop-archives-2.5.2.jar!/org/apache/hadoop/tools/HadoopArchives.class")
      
              when:
              println url
              def path = url.getPath()
              println path
              def other = URLDecoder.decode(path, "UTF-8")
              println other
      
              then:
              path.contains("+")
              other.contains("+")
          }
      }
      

      This was run into while attempting to create a HAR file, while my hadoop-archives.jar was in a directory that had a + char in its name.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              seanstory Sean Story
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: