[vcs-log] move isBroken check out of invokeLater
authorJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Fri, 21 Oct 2016 13:51:50 +0000 (16:51 +0300)
committerJulia Beliaeva <Julia.Beliaeva@jetbrains.com>
Sat, 29 Oct 2016 18:33:47 +0000 (21:33 +0300)
platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java

index 3e07fadd562182c289864ee806b3774b61c48f81..4e5a27873376f68025cdbb1407d8fc0fb6d08551 100644 (file)
@@ -49,6 +49,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.*;
 import java.util.Collection;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class VcsLogManager implements Disposable {
   public static final ExtensionPointName<VcsLogProvider> LOG_PROVIDER_EP = ExtensionPointName.create("com.intellij.logProvider");
@@ -206,36 +207,36 @@ public class VcsLogManager implements Disposable {
   }
 
   private class MyFatalErrorsHandler implements FatalErrorHandler {
-    private boolean myIsBroken = false;
+    private final AtomicBoolean myIsBroken = new AtomicBoolean(false);
 
     @Override
     public void consume(@Nullable Object source, @NotNull final Exception e) {
-      ApplicationManager.getApplication().invokeLater(() -> {
-        if (!myIsBroken) {
-          myIsBroken = true;
-          processErrorFirstTime(source, e);
-        }
-        else {
-          LOG.debug(e);
-        }
-      });
+      if (myIsBroken.compareAndSet(false, true)) {
+        processErrorFirstTime(source, e);
+      }
+      else {
+        LOG.debug(e);
+      }
     }
 
     protected void processErrorFirstTime(@Nullable Object source, @NotNull Exception e) {
       if (myRecreateMainLogHandler != null) {
-        String message = "Fatal error, VCS Log recreated: " + e.getMessage();
-        if (isLogVisible()) {
-          LOG.info(e);
-          VcsBalloonProblemNotifier.showOverChangesView(myProject, message, MessageType.ERROR);
-        }
-        else {
-          LOG.error(message, e);
-        }
-        myRecreateMainLogHandler.run();
+        ApplicationManager.getApplication().invokeLater(() -> {
+          String message = "Fatal error, VCS Log recreated: " + e.getMessage();
+          if (isLogVisible()) {
+            LOG.info(e);
+            VcsBalloonProblemNotifier.showOverChangesView(myProject, message, MessageType.ERROR);
+          }
+          else {
+            LOG.error(message, e);
+          }
+          myRecreateMainLogHandler.run();
+        });
       }
       else {
         LOG.error(e);
       }
+
       if (source instanceof VcsLogStorage) {
         myLogData.getIndex().markCorrupted();
       }