Skip to content

Commit 435cf77

Browse files
committed
HADOOP-8587. HarFileSystem access of harMetaCache isn't threadsafe. Contributed by Eli Collins
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1360448 13f79535-47bb-0310-9956-ffa450edef68
1 parent f625a61 commit 435cf77

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ Branch-2 ( Unreleased changes )
331331
HADOOP-3886. Error in javadoc of Reporter, Mapper and Progressable
332332
(Jingguo Yao via harsh)
333333

334+
HADOOP-8587. HarFileSystem access of harMetaCache isn't threadsafe. (eli)
335+
334336
BREAKDOWN OF HDFS-3042 SUBTASKS
335337

336338
HADOOP-8220. ZKFailoverController doesn't handle failure to become active

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import java.net.URISyntaxException;
2525
import java.net.URLDecoder;
2626
import java.util.ArrayList;
27-
import java.util.EnumSet;
2827
import java.util.List;
2928
import java.util.Map;
3029
import java.util.TreeMap;
3130
import java.util.HashMap;
31+
import java.util.concurrent.ConcurrentHashMap;
3232

3333
import org.apache.hadoop.conf.Configuration;
3434
import org.apache.hadoop.fs.permission.FsPermission;
@@ -52,7 +52,8 @@
5252
public class HarFileSystem extends FilterFileSystem {
5353
public static final int VERSION = 3;
5454

55-
private static final Map<URI, HarMetaData> harMetaCache = new HashMap<URI, HarMetaData>();
55+
private static final Map<URI, HarMetaData> harMetaCache =
56+
new ConcurrentHashMap<URI, HarMetaData>();
5657

5758
// uri representation of this Har filesystem
5859
private URI uri;
@@ -1055,7 +1056,7 @@ private void parseMetaData() throws IOException {
10551056
FileStatus archiveStat = fs.getFileStatus(archiveIndexPath);
10561057
archiveIndexTimestamp = archiveStat.getModificationTime();
10571058
LineReader aLin;
1058-
String retStr = null;
1059+
10591060
// now start reading the real index file
10601061
for (Store s: stores) {
10611062
read = 0;

0 commit comments

Comments
 (0)