Loading core/java/com/android/internal/infra/AndroidFuture.java +18 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; import com.android.internal.util.function.pooled.PooledLambda; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; Loading Loading @@ -129,7 +130,23 @@ public class AndroidFuture<T> extends CompletableFuture<T> implements Parcelable if (changed) { onCompleted(null, ex); } return super.completeExceptionally(ex); return changed; } @Override public boolean cancel(boolean mayInterruptIfRunning) { boolean changed = super.cancel(mayInterruptIfRunning); if (changed) { try { get(); throw new IllegalStateException("Expected CancellationException"); } catch (CancellationException ex) { onCompleted(null, ex); } catch (Throwable e) { throw new IllegalStateException("Expected CancellationException", e); } } return changed; } @CallSuper Loading Loading
core/java/com/android/internal/infra/AndroidFuture.java +18 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.util.Preconditions; import com.android.internal.util.function.pooled.PooledLambda; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; Loading Loading @@ -129,7 +130,23 @@ public class AndroidFuture<T> extends CompletableFuture<T> implements Parcelable if (changed) { onCompleted(null, ex); } return super.completeExceptionally(ex); return changed; } @Override public boolean cancel(boolean mayInterruptIfRunning) { boolean changed = super.cancel(mayInterruptIfRunning); if (changed) { try { get(); throw new IllegalStateException("Expected CancellationException"); } catch (CancellationException ex) { onCompleted(null, ex); } catch (Throwable e) { throw new IllegalStateException("Expected CancellationException", e); } } return changed; } @CallSuper Loading