From 03e554e8c204d8c34a53aa82b0beec24ca5d1e2f Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Fri, 21 Oct 2016 16:51:50 +0300 Subject: [PATCH] [vcs-log] move isBroken check out of invokeLater --- .../intellij/vcs/log/impl/VcsLogManager.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java index 3e07fadd5621..4e5a27873376 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/impl/VcsLogManager.java @@ -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 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(); }