From 3ff5a6f970d70ac2b065479a819d7a2df97087e7 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 12 Dec 2022 09:00:03 -0800 Subject: [PATCH] More reliably use transitional `@CheckForNull` and `@ParametricNullness` annotations. I would assume we're still not 100% consistent in using them, and we might someday consider an Error Prone check to identify the remaining places that we ought to be using them. But in an ideal world, they'll be able to go away entirely before we need to bother. (There are a few reasons to use these annotations, but the one that I was poking at today was trying to [run NullAway](https://github.com/google/guava/issues/2484#issuecomment-1203200500).) RELNOTES=n/a PiperOrigin-RevId: 494743544 --- .../com/google/common/cache/CacheBuilder.java | 16 ++++++------ .../collect/AbstractMapBasedMultimap.java | 1 + .../common/collect/ImmutableListMultimap.java | 3 +-- .../src/com/google/common/collect/Maps.java | 1 + .../google/common/collect/Synchronized.java | 25 +++++++++++-------- .../src/com/google/common/io/ByteSource.java | 1 + .../util/concurrent/CollectionFuture.java | 4 +-- .../util/concurrent/ImmediateFuture.java | 4 ++- .../util/concurrent/SimpleTimeLimiter.java | 3 +++ .../common/util/concurrent/TimeLimiter.java | 2 ++ .../com/google/common/cache/CacheBuilder.java | 16 ++++++------ .../collect/AbstractMapBasedMultimap.java | 1 + .../common/collect/ImmutableListMultimap.java | 2 +- .../google/common/collect/ImmutableSet.java | 2 +- guava/src/com/google/common/collect/Maps.java | 1 + .../google/common/collect/MoreCollectors.java | 3 ++- .../google/common/collect/Synchronized.java | 25 +++++++++++-------- .../src/com/google/common/io/ByteSource.java | 1 + .../util/concurrent/CollectionFuture.java | 4 +-- .../util/concurrent/ImmediateFuture.java | 4 ++- .../util/concurrent/SimpleTimeLimiter.java | 3 +++ .../common/util/concurrent/TimeLimiter.java | 4 +++ 22 files changed, 77 insertions(+), 49 deletions(-) diff --git a/android/guava/src/com/google/common/cache/CacheBuilder.java b/android/guava/src/com/google/common/cache/CacheBuilder.java index 6f467dedd55f..e39c22495472 100644 --- a/android/guava/src/com/google/common/cache/CacheBuilder.java +++ b/android/guava/src/com/google/common/cache/CacheBuilder.java @@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.qual.Nullable; +import javax.annotation.CheckForNull; /** * A builder of {@link LoadingCache} and {@link Cache} instances. @@ -276,10 +276,10 @@ public long read() { int concurrencyLevel = UNSET_INT; long maximumSize = UNSET_INT; long maximumWeight = UNSET_INT; - @Nullable Weigher weigher; + @CheckForNull Weigher weigher; - @Nullable Strength keyStrength; - @Nullable Strength valueStrength; + @CheckForNull Strength keyStrength; + @CheckForNull Strength valueStrength; @SuppressWarnings("GoodTime") // should be a java.time.Duration long expireAfterWriteNanos = UNSET_INT; @@ -290,11 +290,11 @@ public long read() { @SuppressWarnings("GoodTime") // should be a java.time.Duration long refreshNanos = UNSET_INT; - @Nullable Equivalence keyEquivalence; - @Nullable Equivalence valueEquivalence; + @CheckForNull Equivalence keyEquivalence; + @CheckForNull Equivalence valueEquivalence; - @Nullable RemovalListener removalListener; - @Nullable Ticker ticker; + @CheckForNull RemovalListener removalListener; + @CheckForNull Ticker ticker; Supplier statsCounterSupplier = NULL_STATS_COUNTER; diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index 72cf8f1eea5e..9a2612edf4fe 100644 --- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -1175,6 +1175,7 @@ public boolean hasNext() { } @Override + @ParametricNullness public T next() { if (!valueIterator.hasNext()) { Entry> mapEntry = keyIterator.next(); diff --git a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java index 20408db80b1f..612f2f850289 100644 --- a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java +++ b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Map.Entry; import javax.annotation.CheckForNull; -import org.checkerframework.checker.nullness.qual.Nullable; /** * A {@link ListMultimap} whose contents will never change, with many other important properties @@ -280,7 +279,7 @@ public static ImmutableListMultimap copyOf( /** Creates an ImmutableListMultimap from an asMap.entrySet. */ static ImmutableListMultimap fromMapEntries( Collection>> mapEntries, - @Nullable Comparator valueComparator) { + @CheckForNull Comparator valueComparator) { if (mapEntries.isEmpty()) { return of(); } diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java index b75b44f87c32..ee310dc136f6 100644 --- a/android/guava/src/com/google/common/collect/Maps.java +++ b/android/guava/src/com/google/common/collect/Maps.java @@ -1993,6 +1993,7 @@ public interface EntryTransformer< * @throws NullPointerException if the key or value is null and this transformer does not accept * null arguments */ + @ParametricNullness V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value); } diff --git a/android/guava/src/com/google/common/collect/Synchronized.java b/android/guava/src/com/google/common/collect/Synchronized.java index 42bf6114c840..2f30c7622807 100644 --- a/android/guava/src/com/google/common/collect/Synchronized.java +++ b/android/guava/src/com/google/common/collect/Synchronized.java @@ -459,7 +459,7 @@ public int count(@CheckForNull Object o) { } @Override - public int add(E e, int n) { + public int add(@ParametricNullness E e, int n) { synchronized (mutex) { return delegate().add(e, n); } @@ -473,14 +473,14 @@ public int remove(@CheckForNull Object o, int n) { } @Override - public int setCount(E element, int count) { + public int setCount(@ParametricNullness E element, int count) { synchronized (mutex) { return delegate().setCount(element, count); } } @Override - public boolean setCount(E element, int oldCount, int newCount) { + public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) { synchronized (mutex) { return delegate().setCount(element, oldCount, newCount); } @@ -588,21 +588,21 @@ public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object valu } @Override - public Collection get(K key) { + public Collection get(@ParametricNullness K key) { synchronized (mutex) { return typePreservingCollection(delegate().get(key), mutex); } } @Override - public boolean put(K key, V value) { + public boolean put(@ParametricNullness K key, @ParametricNullness V value) { synchronized (mutex) { return delegate().put(key, value); } } @Override - public boolean putAll(K key, Iterable values) { + public boolean putAll(@ParametricNullness K key, Iterable values) { synchronized (mutex) { return delegate().putAll(key, values); } @@ -616,7 +616,7 @@ public boolean putAll(Multimap multimap) { } @Override - public Collection replaceValues(K key, Iterable values) { + public Collection replaceValues(@ParametricNullness K key, Iterable values) { synchronized (mutex) { return delegate().replaceValues(key, values); // copy not synchronized } @@ -1229,7 +1229,7 @@ public Set values() { @Override @CheckForNull - public V forcePut(K key, V value) { + public V forcePut(@ParametricNullness K key, @ParametricNullness V value) { synchronized (mutex) { return delegate().forcePut(key, value); } @@ -1989,7 +1989,10 @@ public void clear() { @Override @CheckForNull - public V put(R rowKey, C columnKey, V value) { + public V put( + @ParametricNullness R rowKey, + @ParametricNullness C columnKey, + @ParametricNullness V value) { synchronized (mutex) { return delegate().put(rowKey, columnKey, value); } @@ -2011,14 +2014,14 @@ public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) { } @Override - public Map row(R rowKey) { + public Map row(@ParametricNullness R rowKey) { synchronized (mutex) { return map(delegate().row(rowKey), mutex); } } @Override - public Map column(C columnKey) { + public Map column(@ParametricNullness C columnKey) { synchronized (mutex) { return map(delegate().column(columnKey), mutex); } diff --git a/android/guava/src/com/google/common/io/ByteSource.java b/android/guava/src/com/google/common/io/ByteSource.java index bf99ee0ca8ae..e443e508f404 100644 --- a/android/guava/src/com/google/common/io/ByteSource.java +++ b/android/guava/src/com/google/common/io/ByteSource.java @@ -316,6 +316,7 @@ public byte[] read() throws IOException { */ @Beta @CanIgnoreReturnValue // some processors won't return a useful result + @ParametricNullness public T read(ByteProcessor processor) throws IOException { checkNotNull(processor); diff --git a/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java b/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java index 1fd18523db04..062aee7a79dc 100644 --- a/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/CollectionFuture.java @@ -102,9 +102,9 @@ static final class ListFuture /** The result of a successful {@code Future}. */ private static final class Present { - final V value; + @ParametricNullness final V value; - Present(V value) { + Present(@ParametricNullness V value) { this.value = value; } } diff --git a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java index 8b1c17ae48be..f09816c4e3cb 100644 --- a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; /** Implementation of {@link Futures#immediateFuture}. */ @@ -98,7 +99,8 @@ static final class ImmediateFailedFuture extends Tru } static final class ImmediateCancelledFuture extends TrustedFuture { - static final @Nullable ImmediateCancelledFuture INSTANCE = + @CheckForNull + static final ImmediateCancelledFuture INSTANCE = AbstractFuture.GENERATE_CANCELLATION_CAUSES ? null : new ImmediateCancelledFuture<>(); ImmediateCancelledFuture() { 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 c6ade6a3a0a5..0c752efd3be8 100644 --- a/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java +++ b/android/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java @@ -111,6 +111,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) return interfaceType.cast(object); } + @ParametricNullness private T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible) throws Exception { @@ -141,6 +142,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) @CanIgnoreReturnValue @Override + @ParametricNullness public T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException, ExecutionException { @@ -163,6 +165,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) @CanIgnoreReturnValue @Override + @ParametricNullness public T callUninterruptiblyWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException { diff --git a/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java index 0883bccee0c1..17e5f0c4a22a 100644 --- a/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java +++ b/android/guava/src/com/google/common/util/concurrent/TimeLimiter.java @@ -99,6 +99,7 @@ public interface TimeLimiter { * @since 22.0 */ @CanIgnoreReturnValue + @ParametricNullness T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException, ExecutionException; @@ -123,6 +124,7 @@ public interface TimeLimiter { * @since 22.0 */ @CanIgnoreReturnValue + @ParametricNullness T callUninterruptiblyWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException; diff --git a/guava/src/com/google/common/cache/CacheBuilder.java b/guava/src/com/google/common/cache/CacheBuilder.java index a609a1a77348..74094ad30705 100644 --- a/guava/src/com/google/common/cache/CacheBuilder.java +++ b/guava/src/com/google/common/cache/CacheBuilder.java @@ -40,7 +40,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import org.checkerframework.checker.nullness.qual.Nullable; +import javax.annotation.CheckForNull; /** * A builder of {@link LoadingCache} and {@link Cache} instances. @@ -277,10 +277,10 @@ public long read() { int concurrencyLevel = UNSET_INT; long maximumSize = UNSET_INT; long maximumWeight = UNSET_INT; - @Nullable Weigher weigher; + @CheckForNull Weigher weigher; - @Nullable Strength keyStrength; - @Nullable Strength valueStrength; + @CheckForNull Strength keyStrength; + @CheckForNull Strength valueStrength; @SuppressWarnings("GoodTime") // should be a java.time.Duration long expireAfterWriteNanos = UNSET_INT; @@ -291,11 +291,11 @@ public long read() { @SuppressWarnings("GoodTime") // should be a java.time.Duration long refreshNanos = UNSET_INT; - @Nullable Equivalence keyEquivalence; - @Nullable Equivalence valueEquivalence; + @CheckForNull Equivalence keyEquivalence; + @CheckForNull Equivalence valueEquivalence; - @Nullable RemovalListener removalListener; - @Nullable Ticker ticker; + @CheckForNull RemovalListener removalListener; + @CheckForNull Ticker ticker; Supplier statsCounterSupplier = NULL_STATS_COUNTER; diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index 4c5a0f0418fb..1e48281bfbe7 100644 --- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -1188,6 +1188,7 @@ public boolean hasNext() { } @Override + @ParametricNullness public T next() { if (!valueIterator.hasNext()) { Entry> mapEntry = keyIterator.next(); diff --git a/guava/src/com/google/common/collect/ImmutableListMultimap.java b/guava/src/com/google/common/collect/ImmutableListMultimap.java index 0184c5bf1f7d..7aef9d567e0e 100644 --- a/guava/src/com/google/common/collect/ImmutableListMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableListMultimap.java @@ -356,7 +356,7 @@ public static ImmutableListMultimap copyOf( /** Creates an ImmutableListMultimap from an asMap.entrySet. */ static ImmutableListMultimap fromMapEntries( Collection>> mapEntries, - @Nullable Comparator valueComparator) { + @CheckForNull Comparator valueComparator) { if (mapEntries.isEmpty()) { return of(); } diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java index 71577303df9d..252fb817ce2c 100644 --- a/guava/src/com/google/common/collect/ImmutableSet.java +++ b/guava/src/com/google/common/collect/ImmutableSet.java @@ -724,7 +724,7 @@ static int chooseTableSize(int setSize) { */ private static final class RegularSetBuilderImpl extends SetBuilderImpl { // null until at least two elements are present - private @Nullable Object @Nullable [] hashTable; + @CheckForNull private @Nullable Object[] hashTable; private int maxRunBeforeFallback; private int expandTableThreshold; private int hashCode; diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java index b4f48e1634a9..dadfd17865ff 100644 --- a/guava/src/com/google/common/collect/Maps.java +++ b/guava/src/com/google/common/collect/Maps.java @@ -2121,6 +2121,7 @@ public interface EntryTransformer< * @throws NullPointerException if the key or value is null and this transformer does not accept * null arguments */ + @ParametricNullness V2 transformEntry(@ParametricNullness K key, @ParametricNullness V1 value); } diff --git a/guava/src/com/google/common/collect/MoreCollectors.java b/guava/src/com/google/common/collect/MoreCollectors.java index 5a84a4628e3b..3c57ea0a9388 100644 --- a/guava/src/com/google/common/collect/MoreCollectors.java +++ b/guava/src/com/google/common/collect/MoreCollectors.java @@ -25,6 +25,7 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.stream.Collector; +import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -93,7 +94,7 @@ public final class MoreCollectors { private static final class ToOptionalState { static final int MAX_EXTRAS = 4; - @Nullable Object element; + @CheckForNull Object element; List extras; ToOptionalState() { diff --git a/guava/src/com/google/common/collect/Synchronized.java b/guava/src/com/google/common/collect/Synchronized.java index 29fe61a89b8a..3dd365af68f0 100644 --- a/guava/src/com/google/common/collect/Synchronized.java +++ b/guava/src/com/google/common/collect/Synchronized.java @@ -516,7 +516,7 @@ public int count(@CheckForNull Object o) { } @Override - public int add(E e, int n) { + public int add(@ParametricNullness E e, int n) { synchronized (mutex) { return delegate().add(e, n); } @@ -530,14 +530,14 @@ public int remove(@CheckForNull Object o, int n) { } @Override - public int setCount(E element, int count) { + public int setCount(@ParametricNullness E element, int count) { synchronized (mutex) { return delegate().setCount(element, count); } } @Override - public boolean setCount(E element, int oldCount, int newCount) { + public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) { synchronized (mutex) { return delegate().setCount(element, oldCount, newCount); } @@ -645,21 +645,21 @@ public boolean containsEntry(@CheckForNull Object key, @CheckForNull Object valu } @Override - public Collection get(K key) { + public Collection get(@ParametricNullness K key) { synchronized (mutex) { return typePreservingCollection(delegate().get(key), mutex); } } @Override - public boolean put(K key, V value) { + public boolean put(@ParametricNullness K key, @ParametricNullness V value) { synchronized (mutex) { return delegate().put(key, value); } } @Override - public boolean putAll(K key, Iterable values) { + public boolean putAll(@ParametricNullness K key, Iterable values) { synchronized (mutex) { return delegate().putAll(key, values); } @@ -673,7 +673,7 @@ public boolean putAll(Multimap multimap) { } @Override - public Collection replaceValues(K key, Iterable values) { + public Collection replaceValues(@ParametricNullness K key, Iterable values) { synchronized (mutex) { return delegate().replaceValues(key, values); // copy not synchronized } @@ -1376,7 +1376,7 @@ public Set values() { @Override @CheckForNull - public V forcePut(K key, V value) { + public V forcePut(@ParametricNullness K key, @ParametricNullness V value) { synchronized (mutex) { return delegate().forcePut(key, value); } @@ -2136,7 +2136,10 @@ public void clear() { @Override @CheckForNull - public V put(R rowKey, C columnKey, V value) { + public V put( + @ParametricNullness R rowKey, + @ParametricNullness C columnKey, + @ParametricNullness V value) { synchronized (mutex) { return delegate().put(rowKey, columnKey, value); } @@ -2158,14 +2161,14 @@ public V remove(@CheckForNull Object rowKey, @CheckForNull Object columnKey) { } @Override - public Map row(R rowKey) { + public Map row(@ParametricNullness R rowKey) { synchronized (mutex) { return map(delegate().row(rowKey), mutex); } } @Override - public Map column(C columnKey) { + public Map column(@ParametricNullness C columnKey) { synchronized (mutex) { return map(delegate().column(columnKey), mutex); } diff --git a/guava/src/com/google/common/io/ByteSource.java b/guava/src/com/google/common/io/ByteSource.java index bf99ee0ca8ae..e443e508f404 100644 --- a/guava/src/com/google/common/io/ByteSource.java +++ b/guava/src/com/google/common/io/ByteSource.java @@ -316,6 +316,7 @@ public byte[] read() throws IOException { */ @Beta @CanIgnoreReturnValue // some processors won't return a useful result + @ParametricNullness public T read(ByteProcessor processor) throws IOException { checkNotNull(processor); diff --git a/guava/src/com/google/common/util/concurrent/CollectionFuture.java b/guava/src/com/google/common/util/concurrent/CollectionFuture.java index 1fd18523db04..062aee7a79dc 100644 --- a/guava/src/com/google/common/util/concurrent/CollectionFuture.java +++ b/guava/src/com/google/common/util/concurrent/CollectionFuture.java @@ -102,9 +102,9 @@ static final class ListFuture /** The result of a successful {@code Future}. */ private static final class Present { - final V value; + @ParametricNullness final V value; - Present(V value) { + Present(@ParametricNullness V value) { this.value = value; } } diff --git a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java index 8b1c17ae48be..f09816c4e3cb 100644 --- a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java +++ b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; /** Implementation of {@link Futures#immediateFuture}. */ @@ -98,7 +99,8 @@ static final class ImmediateFailedFuture extends Tru } static final class ImmediateCancelledFuture extends TrustedFuture { - static final @Nullable ImmediateCancelledFuture INSTANCE = + @CheckForNull + static final ImmediateCancelledFuture INSTANCE = AbstractFuture.GENERATE_CANCELLATION_CAUSES ? null : new ImmediateCancelledFuture<>(); ImmediateCancelledFuture() { diff --git a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java index c6ade6a3a0a5..0c752efd3be8 100644 --- a/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java +++ b/guava/src/com/google/common/util/concurrent/SimpleTimeLimiter.java @@ -111,6 +111,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) return interfaceType.cast(object); } + @ParametricNullness private T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible) throws Exception { @@ -141,6 +142,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) @CanIgnoreReturnValue @Override + @ParametricNullness public T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException, ExecutionException { @@ -163,6 +165,7 @@ private static T newProxy(Class interfaceType, InvocationHandler handler) @CanIgnoreReturnValue @Override + @ParametricNullness public T callUninterruptiblyWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException { diff --git a/guava/src/com/google/common/util/concurrent/TimeLimiter.java b/guava/src/com/google/common/util/concurrent/TimeLimiter.java index 0245fec3ca87..9f37b941cc4a 100644 --- a/guava/src/com/google/common/util/concurrent/TimeLimiter.java +++ b/guava/src/com/google/common/util/concurrent/TimeLimiter.java @@ -146,6 +146,7 @@ default T newProxy(T target, Class interfaceType, Duration timeout) { */ @SuppressWarnings("GoodTime") // should accept a java.time.Duration @CanIgnoreReturnValue + @ParametricNullness T callWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException, ExecutionException; @@ -167,6 +168,7 @@ default T newProxy(T target, Class interfaceType, Duration timeout) { * @since 28.0 */ @CanIgnoreReturnValue + @ParametricNullness default T callWithTimeout(Callable callable, Duration timeout) throws TimeoutException, InterruptedException, ExecutionException { return callWithTimeout(callable, toNanosSaturated(timeout), TimeUnit.NANOSECONDS); @@ -193,6 +195,7 @@ default T newProxy(T target, Class interfaceType, Duration timeout) { */ @SuppressWarnings("GoodTime") // should accept a java.time.Duration @CanIgnoreReturnValue + @ParametricNullness T callUninterruptiblyWithTimeout( Callable callable, long timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, ExecutionException; @@ -216,6 +219,7 @@ default T newProxy(T target, Class interfaceType, Duration timeout) { * @since 28.0 */ @CanIgnoreReturnValue + @ParametricNullness default T callUninterruptiblyWithTimeout( Callable callable, Duration timeout) throws TimeoutException, ExecutionException { return callUninterruptiblyWithTimeout(