From cd0b89ebf8244b7b6fcbb50737d1f7e0379d85b9 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 14 Sep 2017 19:54:54 +0300 Subject: [PATCH] BgTaskUtil.executeOnPooledThread: catch and ignore PCE It is expected for the task to throw the PCE (e.g. on dispose). It fixes EA-107241 where the PCE is thrown during future.get(). --- .../openapi/progress/util/BackgroundTaskUtil.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/progress/util/BackgroundTaskUtil.java b/platform/platform-impl/src/com/intellij/openapi/progress/util/BackgroundTaskUtil.java index 06aaae5eb63d..7545743e0d1a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/progress/util/BackgroundTaskUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/progress/util/BackgroundTaskUtil.java @@ -194,7 +194,14 @@ public class BackgroundTaskUtil { boolean onPooledThread) { ProgressIndicator indicator = new EmptyProgressIndicator(modalityState); indicator.start(); - Runnable toRun = () -> ProgressManager.getInstance().runProcess(task, indicator); + Runnable toRun = () -> { + try { + ProgressManager.getInstance().runProcess(task, indicator); + } + catch (ProcessCanceledException pce) { + // ignore: expected cancellation + } + }; if (onPooledThread) { CompletableFuture future = CompletableFuture.runAsync(toRun, AppExecutorUtil.getAppExecutorService());