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().
This commit is contained in:
Kirill Likhodedov
2017-09-14 19:56:47 +03:00
parent 2d7101a02d
commit cd0b89ebf8
@@ -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());