Browse Source

HDDS-766. Ozone shell create volume fails if volume name does not have a leading slash. Contributed by chencan.

Márton Elek 6 years ago
parent
commit
96c104d365

+ 6 - 0
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java

@@ -179,6 +179,12 @@ public class OzoneAddress {
     // but any occurrence of them will be quoted by the URI ctor.
     String path = pathString.substring(start, pathString.length());
 
+    // add leading slash to the path, if it does not exist
+    int firstSlash = path.indexOf('/');
+    if(firstSlash != 0) {
+      path = "/" + path;
+    }
+
     if (authority == null || authority.equals("")) {
       authority = EMPTY_HOST;
     }

+ 2 - 1
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java

@@ -45,7 +45,8 @@ public class TestOzoneAddress {
         {"http://localhost:9878/"},
         {"http://localhost/"},
         {"http:///"},
-        {"/"}
+        {"/"},
+        {""}
     });
   }