catch CancellationException

This commit is contained in:
Alexey Kudravtsev
2014-04-11 19:05:21 +04:00
parent 86e8dd82fd
commit 9e36eb10d2
3 changed files with 10 additions and 4 deletions
@@ -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<T> {
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() {
@@ -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();
}
@@ -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);
}
}