diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java index 63b7576249..2b54a7b1ba 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java @@ -179,6 +179,12 @@ private static URI stringToUri(String pathString) { // 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; } diff --git a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java index 319c4cebcc..600cf30db7 100644 --- a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java +++ b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java @@ -45,7 +45,8 @@ public static Collection data() { {"http://localhost:9878/"}, {"http://localhost/"}, {"http:///"}, - {"/"} + {"/"}, + {""} }); }