diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java index 94932ba2a2ac..5730190c8cd1 100644 --- a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java @@ -849,6 +849,7 @@ protected boolean setException(Throwable throwable) { * @since 19.0 */ @CanIgnoreReturnValue + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. protected boolean setFuture(ListenableFuture future) { checkNotNull(future); @RetainedLocalRef Object localValue = value; diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java index 594496884888..a65f7345ce51 100644 --- a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java +++ b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java @@ -458,6 +458,7 @@ private static final class FutureAsCancellable implements Cancellable { } @Override + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. public void cancel(boolean mayInterruptIfRunning) { delegate.cancel(mayInterruptIfRunning); } @@ -627,6 +628,7 @@ private static final class SupplantableFuture implements Cancellable { } @Override + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. public void cancel(boolean mayInterruptIfRunning) { /* * Lock to ensure that a task cannot be rescheduled while a cancel is ongoing. diff --git a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java index eaf084f3b9be..0324acdcfd3e 100644 --- a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java @@ -76,6 +76,7 @@ abstract class AggregateFuture toCancel : inputFutures) { diff --git a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index effa8ef59bab..245c6ade29b9 100644 --- a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -94,6 +94,7 @@ public final void run() { } } + @SuppressWarnings("Interruption") // We are restoring an interrupt on this thread. private void waitForInterrupt(Thread currentThread) { /* * If someone called cancel(true), it is possible that the interrupted bit hasn't been set yet. @@ -189,6 +190,7 @@ private void waitForInterrupt(Thread currentThread) { * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can * in turn invoke arbitrary code it is not safe to call while holding a lock. */ + @SuppressWarnings("Interruption") // We are implementing a user-requested interrupt. final void interruptTask() { // Since the Thread is replaced by DONE before run() invokes listeners or returns, if we succeed // in this CAS, there's no risk of interrupting the wrong thread or interrupting a thread that diff --git a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java index 63c146395b18..599e31c584c4 100644 --- a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java +++ b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java @@ -602,6 +602,7 @@ protected String pendingToString() { @SuppressWarnings({ "GoodTime", // should accept a java.time.Duration "CatchingUnchecked", // sneaky checked exception + "Interruption", // We copy AbstractExecutorService.invokeAny. Maybe we shouldn't: b/227335009. }) @J2ktIncompatible @GwtIncompatible diff --git a/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java index 5d8df07771eb..5d2713204bc4 100644 --- a/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java +++ b/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java @@ -49,6 +49,8 @@ @J2ktIncompatible @GwtIncompatible @ElementTypesAreNonnullByDefault +// TODO: b/227335009 - Maybe change interruption behavior, but it requires thought. +@SuppressWarnings("Interruption") public final class SimpleTimeLimiter implements TimeLimiter { private final ExecutorService executor; diff --git a/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java b/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java index b3f7f1346e5b..c8f61bda5423 100644 --- a/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/TimeoutFuture.java @@ -92,6 +92,8 @@ private static final class Fire implements Runnable } @Override + // TODO: b/227335009 - Maybe change interruption behavior, but it requires thought. + @SuppressWarnings("Interruption") public void run() { // If either of these reads return null then we must be after a successful cancel or another // call to this method. diff --git a/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java index f7fcf5421c56..9cb9d30b1c7a 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java +++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java @@ -849,6 +849,7 @@ protected boolean setException(Throwable throwable) { * @since 19.0 */ @CanIgnoreReturnValue + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. protected boolean setFuture(ListenableFuture future) { checkNotNull(future); @RetainedLocalRef Object localValue = value; diff --git a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java index 2529d4749469..003b1279b388 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java @@ -500,6 +500,7 @@ private static final class FutureAsCancellable implements Cancellable { } @Override + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. public void cancel(boolean mayInterruptIfRunning) { delegate.cancel(mayInterruptIfRunning); } @@ -669,6 +670,7 @@ private static final class SupplantableFuture implements Cancellable { } @Override + @SuppressWarnings("Interruption") // We are propagating an interrupt from a caller. public void cancel(boolean mayInterruptIfRunning) { /* * Lock to ensure that a task cannot be rescheduled while a cancel is ongoing. diff --git a/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/guava/src/com/google/common/util/concurrent/AggregateFuture.java index eaf084f3b9be..0324acdcfd3e 100644 --- a/guava/src/com/google/common/util/concurrent/AggregateFuture.java +++ b/guava/src/com/google/common/util/concurrent/AggregateFuture.java @@ -76,6 +76,7 @@ abstract class AggregateFuture toCancel : inputFutures) { diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index effa8ef59bab..245c6ade29b9 100644 --- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -94,6 +94,7 @@ public final void run() { } } + @SuppressWarnings("Interruption") // We are restoring an interrupt on this thread. private void waitForInterrupt(Thread currentThread) { /* * If someone called cancel(true), it is possible that the interrupted bit hasn't been set yet. @@ -189,6 +190,7 @@ private void waitForInterrupt(Thread currentThread) { * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can * in turn invoke arbitrary code it is not safe to call while holding a lock. */ + @SuppressWarnings("Interruption") // We are implementing a user-requested interrupt. final void interruptTask() { // Since the Thread is replaced by DONE before run() invokes listeners or returns, if we succeed // in this CAS, there's no risk of interrupting the wrong thread or interrupting a thread that diff --git a/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/guava/src/com/google/common/util/concurrent/MoreExecutors.java index 2df6db458255..a2f762176dd8 100644 --- a/guava/src/com/google/common/util/concurrent/MoreExecutors.java +++ b/guava/src/com/google/common/util/concurrent/MoreExecutors.java @@ -680,6 +680,7 @@ protected String pendingToString() { @SuppressWarnings({ "GoodTime", // should accept a java.time.Duration "CatchingUnchecked", // sneaky checked exception + "Interruption", // We copy AbstractExecutorService.invokeAny. Maybe we shouldn't: b/227335009. }) @J2ktIncompatible @GwtIncompatible diff --git a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java index 5d8df07771eb..5d2713204bc4 100644 --- a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java +++ b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java @@ -49,6 +49,8 @@ @J2ktIncompatible @GwtIncompatible @ElementTypesAreNonnullByDefault +// TODO: b/227335009 - Maybe change interruption behavior, but it requires thought. +@SuppressWarnings("Interruption") public final class SimpleTimeLimiter implements TimeLimiter { private final ExecutorService executor; diff --git a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java index b3f7f1346e5b..c8f61bda5423 100644 --- a/guava/src/com/google/common/util/concurrent/TimeoutFuture.java +++ b/guava/src/com/google/common/util/concurrent/TimeoutFuture.java @@ -92,6 +92,8 @@ private static final class Fire implements Runnable } @Override + // TODO: b/227335009 - Maybe change interruption behavior, but it requires thought. + @SuppressWarnings("Interruption") public void run() { // If either of these reads return null then we must be after a successful cancel or another // call to this method.