Cleanup
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 18 Feb 2013 19:36:52 +0000 (20:36 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 18 Feb 2013 19:36:52 +0000 (20:36 +0100)
platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSImpl.java

index eb1f2ce3e61c3d52afb720ae7e5b739c1264038c..159e9e67f1a8b6fa4ae6d773acbe29010335507f 100644 (file)
@@ -43,7 +43,6 @@ import org.jetbrains.annotations.TestOnly;
 
 import java.io.*;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -58,11 +57,12 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
   private final ReadWriteLock myRootsLock = new ReentrantReadWriteLock();
   private final Map<String, VirtualFileSystemEntry> myRoots = new THashMap<String, VirtualFileSystemEntry>(FileUtil.PATH_HASHING_STRATEGY);
   private final TIntObjectHashMap<VirtualFileSystemEntry> myRootsById = new TIntObjectHashMap<VirtualFileSystemEntry>();
-  @Nullable private VirtualFileSystemEntry myFakeRoot;
-  @NotNull private final ConcurrentIntObjectMap<VirtualFileSystemEntry> myIdToDirCache = new StripedLockIntObjectConcurrentHashMap<VirtualFileSystemEntry>();
-
+  private final ConcurrentIntObjectMap<VirtualFileSystemEntry> myIdToDirCache = new StripedLockIntObjectConcurrentHashMap<VirtualFileSystemEntry>();
   private final Object myInputLock = new Object();
 
+  @Nullable private VirtualFileSystemEntry myFakeRoot;
+  private boolean myShutDown = false;
+
   public PersistentFSImpl(@NotNull final MessageBus bus) {
     myEventsBus = bus;
     ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
@@ -78,9 +78,9 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
     performShutdown();
   }
 
-  @NotNull private final AtomicBoolean myShutdownPerformed = new AtomicBoolean(Boolean.FALSE);
-  private void performShutdown() {
-    if (!myShutdownPerformed.getAndSet(Boolean.TRUE)) {
+  private synchronized void performShutdown() {
+    if (!myShutDown) {
+      myShutDown = true;
       LOG.info("VFS dispose started");
       FSRecords.dispose();
       LOG.info("VFS dispose completed");