diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java index 8719e2966b01..93852a239601 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java @@ -140,23 +140,32 @@ public class UpdateRequestsQueue { @TestOnly public void waitUntilRefreshed() { - final Semaphore semaphore = new Semaphore(); - semaphore.down(); - synchronized (myLock) { - final Runnable runnable = new Runnable() { - @Override - public void run() { - semaphore.up(); + 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 (!semaphore.waitFor(10000)) { + LOG.error("Too long VCS update"); + return; + } + + synchronized (myLock) { + if (!myRequestSubmitted || myStopped) { + return; } - }; - if (myRequestSubmitted && !myStopped) { - myWaitingUpdateCompletionQueue.add(runnable); - } else { - runnable.run(); } - } - if (!semaphore.waitFor(10000)) { - LOG.error("Too long VCS update"); } }