Browse Source

Merging change r1101570 for HADOOP-7268 from trunk.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/yahoo-merge@1125200 13f79535-47bb-0310-9956-ffa450edef68
Jitendra Nath Pandey 14 years ago
parent
commit
9fc249d9d0

+ 3 - 2
CHANGES.txt

@@ -27,11 +27,12 @@ Trunk (unreleased changes)
     HADOOP-7223. FileContext createFlag combinations are not clearly defined.
     (suresh)
 
-
     HADOOP-7215. RPC clients must use network interface corresponding to 
     the host in the client's kerberos principal key. (suresh)
 
->>>>>>> .r1087843
+    HADOOP-7268. FileContext.getLocalFSFileContext() behavior needs to be 
+    fixed w.r.t tokens. (jitendra)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 1 - 5
src/java/org/apache/hadoop/fs/FileContext.java

@@ -169,7 +169,6 @@ public final class FileContext {
   
   public static final Log LOG = LogFactory.getLog(FileContext.class);
   public static final FsPermission DEFAULT_PERM = FsPermission.getDefault();
-  volatile private static FileContext localFsSingleton = null;
   
   /**
    * List of files that should be deleted on JVM shutdown.
@@ -388,10 +387,7 @@ public final class FileContext {
    */
   public static FileContext getLocalFSFileContext()
       throws UnsupportedFileSystemException {
-    if (localFsSingleton == null) {
-      localFsSingleton = getFileContext(FsConstants.LOCAL_FS_URI); 
-    }
-    return localFsSingleton;
+    return getFileContext(FsConstants.LOCAL_FS_URI);
   }
 
   /**

+ 8 - 0
src/test/core/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java

@@ -21,7 +21,9 @@ package org.apache.hadoop.fs;
 import java.io.IOException;
 
 import org.apache.hadoop.conf.Configuration;
+import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Test;
 
 public class TestLocalFSFileContextMainOperations extends FileContextMainOperationsBaseTest {
 
@@ -37,4 +39,10 @@ public class TestLocalFSFileContextMainOperations extends FileContextMainOperati
       wd = FileSystem.getLocal(new Configuration()).getWorkingDirectory();
     return wd;
   }
+  
+  @Test
+  public void testFileContextNoCache() throws UnsupportedFileSystemException {
+    FileContext fc1 = FileContext.getLocalFSFileContext();
+    Assert.assertTrue(fc1 != fc);
+  }
 }