From 69dd5fa2d43eefeec112f36b91a13513ac21a763 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Fri, 4 Nov 2016 08:31:43 +0530 Subject: [PATCH] HDFS-11098. Datanode in tests cannot start in Windows after HDFS-10638 (Contributed by Vinayakumar B) --- .../hadoop/hdfs/server/datanode/StorageLocation.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java index a0403955537..1bd37821d2d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/StorageLocation.java @@ -62,8 +62,11 @@ public class StorageLocation implements Comparable{ // make sure all URIs that point to a file have the same scheme try { File uriFile = new File(uri.getPath()); - String absPath = uriFile.getAbsolutePath(); - uri = new URI("file", null, absPath, uri.getQuery(), uri.getFragment()); + String uriStr = uriFile.toURI().normalize().toString(); + if (uriStr.endsWith("/")) { + uriStr = uriStr.substring(0, uriStr.length() - 1); + } + uri = new URI(uriStr); } catch (URISyntaxException e) { throw new IllegalArgumentException( "URI: " + uri + " is not in the expected format");