From aaafa6a7b96be82bece18980b04564846ced24e7 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Wed, 11 Jul 2012 22:31:07 +0000 Subject: [PATCH] HADOOP-8587. HarFileSystem access of harMetaCache isn't threadsafe. Contributed by Eli Collins git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1360450 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../src/main/java/org/apache/hadoop/fs/HarFileSystem.java | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 9d219ca48fe..64847193a63 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -146,6 +146,8 @@ Release 2.0.1-alpha - UNRELEASED HADOOP-3886. Error in javadoc of Reporter, Mapper and Progressable (Jingguo Yao via harsh) + HADOOP-8587. HarFileSystem access of harMetaCache isn't threadsafe. (eli) + BREAKDOWN OF HDFS-3042 SUBTASKS HADOOP-8220. ZKFailoverController doesn't handle failure to become active diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java index 48afb671602..8e03fc35a91 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java @@ -24,11 +24,11 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLDecoder; import java.util.ArrayList; -import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.permission.FsPermission; @@ -52,7 +52,8 @@ import org.apache.hadoop.util.Progressable; public class HarFileSystem extends FilterFileSystem { public static final int VERSION = 3; - private static final Map harMetaCache = new HashMap(); + private static final Map harMetaCache = + new ConcurrentHashMap(); // uri representation of this Har filesystem private URI uri; @@ -1055,7 +1056,7 @@ public class HarFileSystem extends FilterFileSystem { FileStatus archiveStat = fs.getFileStatus(archiveIndexPath); archiveIndexTimestamp = archiveStat.getModificationTime(); LineReader aLin; - String retStr = null; + // now start reading the real index file for (Store s: stores) { read = 0;