From 1bbebd1e3ff15a4804d51d26a6821a3e227e6ecb Mon Sep 17 00:00:00 2001 From: Jitendra Nath Pandey Date: Tue, 10 May 2011 18:01:39 +0000 Subject: [PATCH] HADOOP-7268. FileContext.getLocalFSFileContext() behavior needs to be fixed w.r.t tokens. Contributed by jitendra. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1101570 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ src/java/org/apache/hadoop/fs/FileContext.java | 6 +----- .../hadoop/fs/TestLocalFSFileContextMainOperations.java | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) 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 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); } /** 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 @@ 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); + } }