diff --git a/CHANGES.txt b/CHANGES.txt index 7bc0fe7d6b..d141262a6d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -188,6 +188,9 @@ Trunk (unreleased changes) HADOOP-7261. Disable IPV6 for junit tests. (suresh) + HADOOP-7268. FileContext.getLocalFSFileContext() behavior needs to be fixed + w.r.t tokens. (jitendra) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/fs/FileContext.java b/src/java/org/apache/hadoop/fs/FileContext.java index 7481fb9d09..9d5f8ac221 100644 --- a/src/java/org/apache/hadoop/fs/FileContext.java +++ b/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 static FileContext getFileContext() */ public static FileContext getLocalFSFileContext() throws UnsupportedFileSystemException { - if (localFsSingleton == null) { - localFsSingleton = getFileContext(FsConstants.LOCAL_FS_URI); - } - return localFsSingleton; + return getFileContext(FsConstants.LOCAL_FS_URI); } /** diff --git a/src/test/core/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java b/src/test/core/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java index fc05634978..901b6c96ea 100644 --- a/src/test/core/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java +++ b/src/test/core/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java @@ -21,7 +21,9 @@ 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 @@ protected Path getDefaultWorkingDirectory() throws IOException { wd = FileSystem.getLocal(new Configuration()).getWorkingDirectory(); return wd; } + + @Test + public void testFileContextNoCache() throws UnsupportedFileSystemException { + FileContext fc1 = FileContext.getLocalFSFileContext(); + Assert.assertTrue(fc1 != fc); + } }