You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2013/07/09 20:26:09 UTC

svn commit: r1501435 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/fs/HarFileSystem.java src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java

Author: cnauroth
Date: Tue Jul  9 18:26:08 2013
New Revision: 1501435

URL: http://svn.apache.org/r1501435
Log:
HADOOP-8440. Merging change r1501424 from trunk to branch-2.

Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1501435&r1=1501434&r2=1501435&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Tue Jul  9 18:26:08 2013
@@ -531,6 +531,9 @@ Release 2.1.0-beta - 2013-07-02
     HADOOP-9665. Fixed BlockDecompressorStream#decompress to return -1 rather
     than throw EOF at end of file. (Zhijie Shen via acmurthy)
 
+    HADOOP-8440. HarFileSystem.decodeHarURI fails for URIs whose host contains
+    numbers. (Ivan Mitic via cnauroth)
+
 Release 2.0.5-alpha - 06/06/2013
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java?rev=1501435&r1=1501434&r2=1501435&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java Tue Jul  9 18:26:08 2013
@@ -204,35 +204,36 @@ public class HarFileSystem extends Filte
       //create a path 
       return FileSystem.getDefaultUri(conf);
     }
-    String host = rawURI.getHost();
-    if (host == null) {
+    String authority = rawURI.getAuthority();
+    if (authority == null) {
       throw new IOException("URI: " + rawURI
-          + " is an invalid Har URI since host==null."
+          + " is an invalid Har URI since authority==null."
           + "  Expecting har://<scheme>-<host>/<path>.");
     }
-    int i = host.indexOf('-');
+ 
+    int i = authority.indexOf('-');
     if (i < 0) {
       throw new IOException("URI: " + rawURI
           + " is an invalid Har URI since '-' not found."
           + "  Expecting har://<scheme>-<host>/<path>.");
     }
-    final String underLyingScheme = host.substring(0, i);
-    i++;
-    final String underLyingHost = i == host.length()? null: host.substring(i);
-    int underLyingPort = rawURI.getPort();
-    String auth = (underLyingHost == null && underLyingPort == -1)?
-                  null:(underLyingHost+
-                      (underLyingPort == -1 ? "" : ":"+underLyingPort));
-    URI tmp = null;
+ 
     if (rawURI.getQuery() != null) {
       // query component not allowed
       throw new IOException("query component in Path not supported  " + rawURI);
     }
+ 
+    URI tmp = null;
+ 
     try {
-      tmp = new URI(underLyingScheme, auth, rawURI.getPath(), 
-            rawURI.getQuery(), rawURI.getFragment());
+      // convert <scheme>-<host> to <scheme>://<host>
+      URI baseUri = new URI(authority.replaceFirst("-", "://"));
+ 
+      tmp = new URI(baseUri.getScheme(), baseUri.getAuthority(),
+            rawURI.getPath(), rawURI.getQuery(), rawURI.getFragment());
     } catch (URISyntaxException e) {
-        // do nothing should not happen
+      throw new IOException("URI: " + rawURI
+          + " is an invalid Har URI. Expecting har://<scheme>-<host>/<path>.");
     }
     return tmp;
   }

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java?rev=1501435&r1=1501434&r2=1501435&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java Tue Jul  9 18:26:08 2013
@@ -33,6 +33,8 @@ public class TestHarFileSystem {
     checkInvalidPath("har://hdfs/foo.har", conf);
     checkInvalidPath("har://-hdfs/foo.har", conf);
     checkInvalidPath("har://-/foo.har", conf);
+    checkInvalidPath("har://127.0.0.1-/foo.har", conf);
+    checkInvalidPath("har://127.0.0.1/foo.har", conf);
   }
 
   static void checkInvalidPath(String s, Configuration conf) {