From 96c104d365bed3d7648caf2bd6cb70a7ab6f6882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Thu, 22 Nov 2018 15:38:21 +0100 Subject: [PATCH] HDDS-766. Ozone shell create volume fails if volume name does not have a leading slash. Contributed by chencan. --- .../org/apache/hadoop/ozone/web/ozShell/OzoneAddress.java | 6 ++++++ .../apache/hadoop/ozone/web/ozShell/TestOzoneAddress.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 63b7576249a..2b54a7b1ba1 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 @@ 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; } 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 319c4cebcc0..600cf30db7e 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 class TestOzoneAddress { {"http://localhost:9878/"}, {"http://localhost/"}, {"http:///"}, - {"/"} + {"/"}, + {""} }); }