Kaynağa Gözat

HADOOP-1373. checkPath() should ignore case when it compares authoriy. (Edward J. Yoon via rangadi)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.17@647002 13f79535-47bb-0310-9956-ffa450edef68
Raghu Angadi 17 yıl önce
ebeveyn
işleme
ee14df5ced

+ 3 - 0
CHANGES.txt

@@ -547,6 +547,9 @@ Release 0.17.0 - Unreleased
 
    HADOOP-3223. Fix typo in help message for -chmod. (rangadi)
 
+   HADOOP-1373. checkPath() should ignore case when it compares authoriy.
+   (Edward J. Yoon via rangadi)
+
 Release 0.16.3 - Unreleased
 
   BUG FIXES

+ 6 - 4
src/java/org/apache/hadoop/fs/FileSystem.java

@@ -292,16 +292,18 @@ public abstract class FileSystem extends Configured implements Closeable {
     String thatScheme = uri.getScheme();
     String thisAuthority = this.getUri().getAuthority();
     String thatAuthority = uri.getAuthority();
-    if (thisScheme.equals(thatScheme)) {          // schemes match
+    //authority and scheme are not case sensitive
+    if (thisScheme.equalsIgnoreCase(thatScheme)) {// schemes match
       if (thisAuthority == thatAuthority ||       // & authorities match
-          (thisAuthority != null && thisAuthority.equals(thatAuthority)))
+          (thisAuthority != null && 
+           thisAuthority.equalsIgnoreCase(thatAuthority)))
         return;
 
       if (thatAuthority == null &&                // path's authority is null
           thisAuthority != null) {                // fs has an authority
         URI defaultUri = getDefaultUri(getConf()); // & is the default fs
-        if (thisScheme.equals(defaultUri.getScheme()) &&
-            thisAuthority.equals(defaultUri.getAuthority()))
+        if (thisScheme.equalsIgnoreCase(defaultUri.getScheme()) &&
+            thisAuthority.equalsIgnoreCase(defaultUri.getAuthority()))
           return;
       }
       throw new IllegalArgumentException("Wrong FS: "+path+

+ 9 - 1
src/test/org/apache/hadoop/fs/TestFileSystem.java

@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Random;
+import java.net.InetSocketAddress;
 import java.net.URI;
 
 import junit.framework.TestCase;
@@ -509,6 +510,7 @@ public class TestFileSystem extends TestCase {
         cluster = new MiniDFSCluster(new Configuration(), 2, true, null);
         URI uri = cluster.getFileSystem().getUri();
         FileSystem fs = FileSystem.get(uri, new Configuration());
+        checkPath(cluster, fs);
         for(int i = 0; i < 100; i++) {
           assertTrue(fs == FileSystem.get(uri, new Configuration()));
         }
@@ -517,7 +519,13 @@ public class TestFileSystem extends TestCase {
       }
     }
   }
-    
+  
+  private void checkPath(MiniDFSCluster cluster, FileSystem fileSys) throws IOException {
+    InetSocketAddress add = cluster.getNameNode().getNameNodeAddress();
+    // Test upper/lower case
+    fileSys.checkPath(new Path("hdfs://" + add.getHostName().toUpperCase() + ":" + add.getPort()));
+  }
+
   public void testFsClose() throws Exception {
     {
       Configuration conf = new Configuration();