From dfef5a13be4d322c279bf0131b796d2688200ff6 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 28 May 2015 13:45:04 +0200 Subject: [PATCH] silence InterruptedException when closing project during indexing (IDEA-140662) --- .../openapi/project/DumbServiceImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index e03aac15b554..948d347913da 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -414,7 +414,7 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica @Nullable private Pair getNextTask(@Nullable final DumbModeTask prevTask) { final Ref> result = Ref.create(); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { if (myProject.isDisposed()) return; @@ -443,6 +443,22 @@ public class DumbServiceImpl extends DumbService implements Disposable, Modifica return result.get(); } + private static void invokeAndWaitIfNeeded(Runnable runnable) { + if (SwingUtilities.isEventDispatchThread()) { + runnable.run(); + } + else { + try { + SwingUtilities.invokeAndWait(runnable); + } + catch (InterruptedException ignore) { + } + catch (Exception e) { + LOG.error(e); + } + } + } + @Override public long getModificationCount() { return myModificationCount;