diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index a6bd68d7d8a..37dea777282 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -449,6 +449,9 @@ Release 2.8.0 - UNRELEASED HADOOP-11692. Improve authentication failure WARN message to avoid user confusion. (Yongjun Zhang) + HADOOP-11659. o.a.h.fs.FileSystem.Cache#remove should use a single hash map + lookup. (Brahma Reddy Battula via aajisaka) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index 42434f19454..2ca8813ee14 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -2700,10 +2700,12 @@ private FileSystem getInternal(URI uri, Configuration conf, Key key) throws IOEx } synchronized void remove(Key key, FileSystem fs) { - if (map.containsKey(key) && fs == map.get(key)) { - map.remove(key); + FileSystem cachedFs = map.remove(key); + if (fs == cachedFs) { toAutoClose.remove(key); - } + } else if (cachedFs != null) { + map.put(key, cachedFs); + } } synchronized void closeAll() throws IOException { @@ -2730,7 +2732,8 @@ synchronized void closeAll(boolean onlyAutomatic) throws IOException { } //remove from cache - remove(key, fs); + map.remove(key); + toAutoClose.remove(key); if (fs != null) { try {