diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncLoadingCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncLoadingCache.java index 8b60c3168d..f714203e92 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncLoadingCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncLoadingCache.java @@ -18,7 +18,9 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.NullUnmarked; /** * A semi-persistent mapping from keys to values. Values are automatically loaded by the cache @@ -50,7 +52,8 @@ public interface AsyncLoadingCache extends AsyncCache { * @throws RuntimeException or Error if the {@link AsyncCacheLoader} does when constructing the * future, in which case the mapping is left unestablished */ - CompletableFuture get(K key); + @NullUnmarked + @NonNull CompletableFuture get(@NonNull K key); /** * Returns the future of a map of the values associated with {@code keys}, creating or retrieving diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LoadingCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LoadingCache.java index c06aeb2116..f354e84fb9 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LoadingCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LoadingCache.java @@ -19,7 +19,9 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.NullUnmarked; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -62,7 +64,8 @@ public interface LoadingCache extends Cache { * @throws RuntimeException or Error if the {@link CacheLoader} does so, in which case the mapping * is left unestablished */ - V get(K key); + @NullUnmarked + V get(@NonNull K key); /** * Returns a map of the values associated with the {@code keys}, creating or retrieving those @@ -110,7 +113,8 @@ public interface LoadingCache extends Cache { * @throws NullPointerException if the specified key is null */ @CanIgnoreReturnValue - CompletableFuture refresh(K key); + @NullUnmarked + @NonNull CompletableFuture refresh(@NonNull K key); /** * Loads a new value for each {@code key}, asynchronously. While the new value is loading the