hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1071035 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/conf/Configuration.java src/test/core/org/apache/hadoop/conf/TestConfiguration.java
Date Tue, 15 Feb 2011 20:19:33 GMT
Author: todd
Date: Tue Feb 15 20:19:33 2011
New Revision: 1071035

URL: http://svn.apache.org/viewvc?rev=1071035&view=rev
Log:
HADOOP-7145. Configuration.getLocalPath should trim whitespace from the provided directories.
Contributed by Todd Lipcon.

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1071035&r1=1071034&r2=1071035&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Tue Feb 15 20:19:33 2011
@@ -493,6 +493,9 @@ Release 0.22.0 - Unreleased
 
     HADOOP-7094. hadoop.css got lost during project split (cos)
 
+    HADOOP-7145. Configuration.getLocalPath should trim whitespace from
+    the provided directories. (todd)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java?rev=1071035&r1=1071034&r2=1071035&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/conf/Configuration.java Tue Feb 15 20:19:33
2011
@@ -1248,7 +1248,7 @@ public class Configuration implements It
    */
   public Path getLocalPath(String dirsProp, String path)
     throws IOException {
-    String[] dirs = getStrings(dirsProp);
+    String[] dirs = getTrimmedStrings(dirsProp);
     int hashCode = path.hashCode();
     FileSystem fs = FileSystem.getLocal(this);
     for (int i = 0; i < dirs.length; i++) {  // try each local dir
@@ -1280,7 +1280,7 @@ public class Configuration implements It
    */
   public File getFile(String dirsProp, String path)
     throws IOException {
-    String[] dirs = getStrings(dirsProp);
+    String[] dirs = getTrimmedStrings(dirsProp);
     int hashCode = path.hashCode();
     for (int i = 0; i < dirs.length; i++) {  // try each local dir
       int index = (hashCode+i & Integer.MAX_VALUE) % dirs.length;

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java?rev=1071035&r1=1071034&r2=1071035&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/conf/TestConfiguration.java Tue Feb
15 20:19:33 2011
@@ -243,6 +243,30 @@ public class TestConfiguration extends T
     }
   }
 
+  public void testGetLocalPath() throws IOException {
+    Configuration conf = new Configuration();
+    conf.set("dirs", "a, b, c ");
+    for (int i = 0; i < 1000; i++) {
+      String localPath = conf.getLocalPath("dirs", "dir" + i).toString();
+      assertTrue("Path doesn't end in specified dir: " + localPath,
+        localPath.endsWith("dir" + i));
+      assertFalse("Path has internal whitespace: " + localPath,
+        localPath.contains(" "));
+    }
+  }
+  
+  public void testGetFile() throws IOException {
+    Configuration conf = new Configuration();
+    conf.set("dirs", "a, b, c ");
+    for (int i = 0; i < 1000; i++) {
+      String localPath = conf.getFile("dirs", "dir" + i).toString();
+      assertTrue("Path doesn't end in specified dir: " + localPath,
+        localPath.endsWith("dir" + i));
+      assertFalse("Path has internal whitespace: " + localPath,
+        localPath.contains(" "));
+    }
+  }
+
   public void testToString() throws IOException {
     out=new BufferedWriter(new FileWriter(CONFIG));
     startConfig();



Mime
View raw message