further debugging blinking perforce tests
authorpeter <peter@jetbrains.com>
Thu, 12 Jan 2012 17:48:40 +0000 (18:48 +0100)
committerpeter <peter@jetbrains.com>
Thu, 12 Jan 2012 17:48:40 +0000 (18:48 +0100)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java

index 93852a239601b06467eb1964edc4c555a362631f..0adfe9eeb8596829006ffd13eff102911ebd5dcd 100644 (file)
@@ -95,6 +95,10 @@ public class UpdateRequestsQueue {
   }
 
   public void schedule() {
+    if (ChangeListManagerImpl.DEBUG) {
+      System.out.println("UpdateRequestsQueue.schedule");
+    }
+
     synchronized (myLock) {
       if (! myStarted && ApplicationManager.getApplication().isUnitTestMode()) return;
 
@@ -140,31 +144,43 @@ public class UpdateRequestsQueue {
 
   @TestOnly
   public void waitUntilRefreshed() {
-    while (true) {
-      final Semaphore semaphore = new Semaphore();
-      semaphore.down();
-      synchronized (myLock) {
-        final Runnable runnable = new Runnable() {
-          @Override
-          public void run() {
-            semaphore.up();
+    if (ChangeListManagerImpl.DEBUG) {
+      System.out.println("UpdateRequestsQueue.waitUntilRefreshed");
+    }
+
+    try {
+      while (true) {
+        final Semaphore semaphore = new Semaphore();
+        semaphore.down();
+        synchronized (myLock) {
+          final Runnable runnable = new Runnable() {
+            @Override
+            public void run() {
+              semaphore.up();
+            }
+          };
+          if (myRequestSubmitted && !myStopped) {
+            myWaitingUpdateCompletionQueue.add(runnable);
+          }
+          else {
+            runnable.run();
           }
-        };
-        if (myRequestSubmitted && !myStopped) {
-          myWaitingUpdateCompletionQueue.add(runnable);
-        } else {
-          runnable.run();
         }
-      }
-      if (!semaphore.waitFor(10000)) {
-        LOG.error("Too long VCS update");
-        return;
-      }
-
-      synchronized (myLock) {
-        if (!myRequestSubmitted || myStopped) {
+        if (!semaphore.waitFor(10000)) {
+          LOG.error("Too long VCS update");
           return;
         }
+
+        synchronized (myLock) {
+          if (!myRequestSubmitted || myStopped) {
+            return;
+          }
+        }
+      }
+    }
+    finally {
+      if (ChangeListManagerImpl.DEBUG) {
+        System.out.println(" - end - UpdateRequestsQueue.waitUntilRefreshed");
       }
     }
   }