From 9e36eb10d2d9269e95bf5f18cfc85912e173662b Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 11 Apr 2014 13:28:07 +0400 Subject: [PATCH] catch CancellationException --- platform/core-api/src/com/intellij/concurrency/Job.java | 5 +++-- .../codeInsight/daemon/impl/PassExecutorService.java | 7 ++++++- .../src/com/intellij/concurrency/JobLauncherImpl.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/core-api/src/com/intellij/concurrency/Job.java b/platform/core-api/src/com/intellij/concurrency/Job.java index f20917d2e703..50b6fc4618e3 100644 --- a/platform/core-api/src/com/intellij/concurrency/Job.java +++ b/platform/core-api/src/com/intellij/concurrency/Job.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -49,7 +50,7 @@ public interface Job { boolean isDone(); - void waitForCompletion(int millis) throws InterruptedException, ExecutionException, TimeoutException; + void waitForCompletion(int millis) throws InterruptedException, ExecutionException, TimeoutException, CancellationException; @NotNull Job NULL_JOB = new Job() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java index f8b1bcd82c30..3b40edb59869 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PassExecutorService.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ import gnu.trove.THashMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; import java.util.*; import java.util.concurrent.*; @@ -539,6 +540,7 @@ public abstract class PassExecutorService implements Disposable { private static void saveException(Throwable e, DaemonProgressIndicator indicator) { indicator.putUserDataIfAbsent(THROWABLE_KEY, e); } + @TestOnly public static Throwable getSavedException(DaemonProgressIndicator indicator) { return indicator.getUserData(THROWABLE_KEY); } @@ -558,6 +560,9 @@ public abstract class PassExecutorService implements Disposable { catch (InterruptedException e) { return true; } + catch (CancellationException e) { + return true; + } catch (ExecutionException e) { throw e.getCause(); } diff --git a/platform/platform-impl/src/com/intellij/concurrency/JobLauncherImpl.java b/platform/platform-impl/src/com/intellij/concurrency/JobLauncherImpl.java index cface15102e0..b33611da8866 100644 --- a/platform/platform-impl/src/com/intellij/concurrency/JobLauncherImpl.java +++ b/platform/platform-impl/src/com/intellij/concurrency/JobLauncherImpl.java @@ -246,7 +246,7 @@ public class JobLauncherImpl extends JobLauncher { } @Override - public void waitForCompletion(int millis) throws InterruptedException, ExecutionException, TimeoutException { + public void waitForCompletion(int millis) throws InterruptedException, ExecutionException, TimeoutException, CancellationException { get(millis, TimeUnit.MILLISECONDS); } }