|
@@ -2701,10 +2701,12 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
}
|
|
}
|
|
|
|
|
|
synchronized void remove(Key key, FileSystem fs) {
|
|
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);
|
|
toAutoClose.remove(key);
|
|
- }
|
|
|
|
|
|
+ } else if (cachedFs != null) {
|
|
|
|
+ map.put(key, cachedFs);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
synchronized void closeAll() throws IOException {
|
|
synchronized void closeAll() throws IOException {
|
|
@@ -2731,7 +2733,8 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
}
|
|
}
|
|
|
|
|
|
//remove from cache
|
|
//remove from cache
|
|
- remove(key, fs);
|
|
|
|
|
|
+ map.remove(key);
|
|
|
|
+ toAutoClose.remove(key);
|
|
|
|
|
|
if (fs != null) {
|
|
if (fs != null) {
|
|
try {
|
|
try {
|