From eba49b8b1177c4b0171ec38ed9e4674f68e8ca29 Mon Sep 17 00:00:00 2001 From: Harsh J Date: Wed, 12 Oct 2011 03:19:01 +0000 Subject: [PATCH] HADOOP-6490. Use StringUtils over String#replace in Path#normalizePath. Contributed by Uma Maheswara Rao G. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1182189 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/fs/Path.java | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index dcaba89bf00..f22f0796938 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -59,6 +59,9 @@ Trunk (unreleased changes) HADOOP-7721. Add log before login in KerberosAuthenticationHandler. (jitendra) + HADOOP-6490. Use StringUtils over String#replace in Path#normalizePath. + (Uma Maheswara Rao G via harsh) + Release 0.23.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java index 8ac3b6ae532..6c0522360c2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Path.java @@ -18,10 +18,12 @@ package org.apache.hadoop.fs; -import java.net.*; -import java.io.*; -import org.apache.avro.reflect.Stringable; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import org.apache.avro.reflect.Stringable; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -157,8 +159,8 @@ public class Path implements Comparable { private String normalizePath(String path) { // remove double slashes & backslashes - path = path.replace("//", "/"); - path = path.replace("\\", "/"); + path = StringUtils.replace(path, "//", "/"); + path = StringUtils.replace(path, "\\", "/"); // trim trailing slash from non-root path (ignoring windows drive) int minLength = hasWindowsDrive(path, true) ? 4 : 1;