vcs: Always invoke "continuation" for "BackgroundTaskGroup"
authorKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Fri, 28 Oct 2016 06:44:35 +0000 (09:44 +0300)
committerKonstantin Kolosovsky <konstantin.kolosovsky@jetbrains.com>
Wed, 9 Nov 2016 20:53:59 +0000 (23:53 +0300)
Otherwise "QueueProcessor.waitFor()" (and therefore
"BackgroundTaskQueue.waitForTasksToFinish()") will never finish in case
of error/cancellation as "QueueProcessor.isProcessing" flag is set to
"false" only when running "continuation"

platform/vcs-impl/src/com/intellij/openapi/vcs/actions/BackgroundTaskGroup.java

index edaf03450e254ff62f730bd3cd36cb02b1973d1e..10c13ca73a112112f96d0acc952895dee8345ea6 100644 (file)
@@ -68,11 +68,6 @@ public class BackgroundTaskGroup extends BackgroundTaskQueue {
         }
       }
 
-      @Override
-      public void onSuccess() {
-        continuation.run();
-      }
-
       @Override
       public void onCancel() {
         end();
@@ -83,6 +78,11 @@ public class BackgroundTaskGroup extends BackgroundTaskQueue {
         LOG.error(e);
         end();
       }
+
+      @Override
+      public void onFinished() {
+        continuation.run();
+      }
     }.queue());
   }
 
@@ -98,12 +98,10 @@ public class BackgroundTaskGroup extends BackgroundTaskQueue {
         isSuccess = e.isWarning();
       }
       finally {
-        if (isSuccess) {
-          continuation.run();
-        }
-        else {
+        if (!isSuccess) {
           end();
         }
+        continuation.run();
       }
     });
   }