diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/package-info.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/package-info.java new file mode 100644 index 0000000000..5c5a45b927 --- /dev/null +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/local/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.local; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/package-info.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/package-info.java new file mode 100644 index 0000000000..f20678411b --- /dev/null +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/node/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.node; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/package-info.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/package-info.java new file mode 100644 index 0000000000..6a536374b0 --- /dev/null +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ConcurrentHashMapV7.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ConcurrentHashMapV7.java index 968943e251..e0ce547e8a 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ConcurrentHashMapV7.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/ConcurrentHashMapV7.java @@ -113,8 +113,8 @@ * @param the type of keys maintained by this map * @param the type of mapped values */ -@SuppressWarnings({"all", "deprecation", "JdkObsolete", "rawtypes", "serial", "unchecked", - "UnnecessaryParentheses", "UnusedNestedClass", "UnusedVariable", "YodaCondition"}) +@SuppressWarnings({"all", "deprecation", "CheckReturnValue", "JdkObsolete", "rawtypes", "serial", + "unchecked", "UnnecessaryParentheses", "UnusedNestedClass", "UnusedVariable", "YodaCondition"}) public class ConcurrentHashMapV7 extends AbstractMap implements ConcurrentMap, Serializable { private static final long serialVersionUID = 7249069246763182397L; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/package-info.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/package-info.java new file mode 100644 index 0000000000..763f9fa0c5 --- /dev/null +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/impl/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.impl; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/package-info.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/package-info.java new file mode 100644 index 0000000000..6a536374b0 --- /dev/null +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/sketch/package-info.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/sketch/package-info.java new file mode 100644 index 0000000000..0f23542b7b --- /dev/null +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/sketch/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.sketch; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/package-info.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/package-info.java new file mode 100644 index 0000000000..7e490e3225 --- /dev/null +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/ProfilerHook.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/ProfilerHook.java index 72a15dc99b..e9d64345f4 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/ProfilerHook.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/ProfilerHook.java @@ -39,6 +39,7 @@ public abstract class ProfilerHook { calls = new LongAdder(); } + @SuppressWarnings("CheckReturnValue") public final void run() { scheduleStatusTask(); ConcurrentTestHarness.timeTasks(NUM_THREADS, this::profile); diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/package-info.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/package-info.java new file mode 100644 index 0000000000..10dffd255c --- /dev/null +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/profiler/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.profiler; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java index 2cd8041420..6bdf1c02cd 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java @@ -46,6 +46,7 @@ import com.github.benmanes.caffeine.cache.stats.CacheStats; import com.github.benmanes.caffeine.cache.stats.ConcurrentStatsCounter; import com.github.benmanes.caffeine.cache.stats.StatsCounter; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.FormatMethod; /** @@ -291,6 +292,7 @@ public static Caffeine from(String spec) { * @throws IllegalArgumentException if {@code initialCapacity} is negative * @throws IllegalStateException if an initial capacity was already set */ + @CanIgnoreReturnValue public Caffeine initialCapacity(@NonNegative int initialCapacity) { requireState(this.initialCapacity == UNSET_INT, "initial capacity was already set to %s", this.initialCapacity); @@ -324,6 +326,7 @@ int getInitialCapacity() { * @return this {@code Caffeine} instance (for chaining) * @throws NullPointerException if the specified executor is null */ + @CanIgnoreReturnValue public Caffeine executor(Executor executor) { requireState(this.executor == null, "executor was already set to %s", this.executor); this.executor = requireNonNull(executor); @@ -355,6 +358,7 @@ Executor getExecutor() { * @return this {@code Caffeine} instance (for chaining) * @throws NullPointerException if the specified scheduler is null */ + @CanIgnoreReturnValue public Caffeine scheduler(Scheduler scheduler) { requireState(this.scheduler == null, "scheduler was already set to %s", this.scheduler); this.scheduler = requireNonNull(scheduler); @@ -389,6 +393,7 @@ Scheduler getScheduler() { * @throws IllegalArgumentException if {@code size} is negative * @throws IllegalStateException if a maximum size or weight was already set */ + @CanIgnoreReturnValue public Caffeine maximumSize(@NonNegative long maximumSize) { requireState(this.maximumSize == UNSET_INT, "maximum size was already set to %s", this.maximumSize); @@ -425,6 +430,7 @@ public Caffeine maximumSize(@NonNegative long maximumSize) { * @throws IllegalArgumentException if {@code maximumWeight} is negative * @throws IllegalStateException if a maximum weight or size was already set */ + @CanIgnoreReturnValue public Caffeine maximumWeight(@NonNegative long maximumWeight) { requireState(this.maximumWeight == UNSET_INT, "maximum weight was already set to %s", this.maximumWeight); @@ -465,6 +471,7 @@ public Caffeine maximumWeight(@NonNegative long maximumWeight) { * remaining configuration and cache building * @throws IllegalStateException if a weigher was already set */ + @CanIgnoreReturnValue public Caffeine weigher( Weigher weigher) { requireNonNull(weigher); @@ -517,6 +524,7 @@ Weigher getWeigher(boolean isAsync) { * @return this {@code Caffeine} instance (for chaining) * @throws IllegalStateException if the key strength was already set */ + @CanIgnoreReturnValue public Caffeine weakKeys() { requireState(keyStrength == null, "Key strength was already set to %s", keyStrength); keyStrength = Strength.WEAK; @@ -546,6 +554,7 @@ boolean isStrongKeys() { * @return this {@code Caffeine} instance (for chaining) * @throws IllegalStateException if the value strength was already set */ + @CanIgnoreReturnValue public Caffeine weakValues() { requireState(valueStrength == null, "Value strength was already set to %s", valueStrength); valueStrength = Strength.WEAK; @@ -582,6 +591,7 @@ boolean isWeakValues() { * @return this {@code Caffeine} instance (for chaining) * @throws IllegalStateException if the value strength was already set */ + @CanIgnoreReturnValue public Caffeine softValues() { requireState(valueStrength == null, "Value strength was already set to %s", valueStrength); valueStrength = Strength.SOFT; @@ -604,6 +614,7 @@ public Caffeine softValues() { * @throws IllegalStateException if the time to live or variable expiration was already set * @throws ArithmeticException for durations greater than +/- approximately 292 years */ + @CanIgnoreReturnValue public Caffeine expireAfterWrite(Duration duration) { return expireAfterWrite(saturatedToNanos(duration), TimeUnit.NANOSECONDS); } @@ -627,6 +638,7 @@ public Caffeine expireAfterWrite(Duration duration) { * @throws IllegalArgumentException if {@code duration} is negative * @throws IllegalStateException if the time to live or variable expiration was already set */ + @CanIgnoreReturnValue public Caffeine expireAfterWrite(@NonNegative long duration, TimeUnit unit) { requireState(expireAfterWriteNanos == UNSET_INT, "expireAfterWrite was already set to %s ns", expireAfterWriteNanos); @@ -663,6 +675,7 @@ boolean expiresAfterWrite() { * @throws IllegalStateException if the time to idle or variable expiration was already set * @throws ArithmeticException for durations greater than +/- approximately 292 years */ + @CanIgnoreReturnValue public Caffeine expireAfterAccess(Duration duration) { return expireAfterAccess(saturatedToNanos(duration), TimeUnit.NANOSECONDS); } @@ -689,6 +702,7 @@ public Caffeine expireAfterAccess(Duration duration) { * @throws IllegalArgumentException if {@code duration} is negative * @throws IllegalStateException if the time to idle or variable expiration was already set */ + @CanIgnoreReturnValue public Caffeine expireAfterAccess(@NonNegative long duration, TimeUnit unit) { requireState(expireAfterAccessNanos == UNSET_INT, "expireAfterAccess was already set to %s ns", expireAfterAccessNanos); @@ -733,6 +747,7 @@ boolean expiresAfterAccess() { * @return this {@code Caffeine} instance (for chaining) * @throws IllegalStateException if expiration was already set */ + @CanIgnoreReturnValue public Caffeine expireAfter( Expiry expiry) { requireNonNull(expiry); @@ -779,6 +794,7 @@ boolean expiresVariable() { * @throws IllegalStateException if the refresh interval was already set * @throws ArithmeticException for durations greater than +/- approximately 292 years */ + @CanIgnoreReturnValue public Caffeine refreshAfterWrite(Duration duration) { return refreshAfterWrite(saturatedToNanos(duration), TimeUnit.NANOSECONDS); } @@ -806,6 +822,7 @@ public Caffeine refreshAfterWrite(Duration duration) { * @throws IllegalArgumentException if {@code duration} is zero or negative * @throws IllegalStateException if the refresh interval was already set */ + @CanIgnoreReturnValue public Caffeine refreshAfterWrite(@NonNegative long duration, TimeUnit unit) { requireNonNull(unit); requireState(refreshAfterWriteNanos == UNSET_INT, @@ -835,6 +852,7 @@ boolean refreshAfterWrite() { * @throws IllegalStateException if a ticker was already set * @throws NullPointerException if the specified ticker is null */ + @CanIgnoreReturnValue public Caffeine ticker(Ticker ticker) { requireState(this.ticker == null, "Ticker was already set to %s", this.ticker); this.ticker = requireNonNull(ticker); @@ -883,6 +901,7 @@ Ticker getTicker() { * @throws IllegalStateException if a removal listener was already set * @throws NullPointerException if the specified removal listener is null */ + @CanIgnoreReturnValue public Caffeine evictionListener( RemovalListener evictionListener) { requireState(this.evictionListener == null, @@ -934,6 +953,7 @@ public Caffeine evictionListener( * @throws IllegalStateException if a removal listener was already set * @throws NullPointerException if the specified removal listener is null */ + @CanIgnoreReturnValue public Caffeine removalListener( RemovalListener removalListener) { requireState(this.removalListener == null, @@ -961,6 +981,7 @@ public Caffeine removalListener( * * @return this {@code Caffeine} instance (for chaining) */ + @CanIgnoreReturnValue public Caffeine recordStats() { requireState(this.statsCounterSupplier == null, "Statistics recording was already set"); statsCounterSupplier = ENABLED_STATS_COUNTER_SUPPLIER; @@ -977,6 +998,7 @@ public Caffeine recordStats() { * @param statsCounterSupplier a supplier instance that returns a new {@link StatsCounter} * @return this {@code Caffeine} instance (for chaining) */ + @CanIgnoreReturnValue public Caffeine recordStats(Supplier statsCounterSupplier) { requireState(this.statsCounterSupplier == null, "Statistics recording was already set"); requireNonNull(statsCounterSupplier); diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Weigher.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Weigher.java index 001158727b..6ebb447482 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Weigher.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Weigher.java @@ -53,8 +53,8 @@ public interface Weigher { */ static Weigher singletonWeigher() { @SuppressWarnings("unchecked") - Weigher self = (Weigher) SingletonWeigher.INSTANCE; - return self; + Weigher instance = (Weigher) SingletonWeigher.INSTANCE; + return instance; } /** diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/apache/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/apache/package-info.java new file mode 100644 index 0000000000..9270e849a5 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/apache/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.apache; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineSpecGuavaTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineSpecGuavaTest.java index b8a15f8e1e..2e27974ff3 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineSpecGuavaTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineSpecGuavaTest.java @@ -32,7 +32,7 @@ * * @author Adam Winer */ -@SuppressWarnings({"CheckReturnValue", "PreferJavaTimeOverload"}) +@SuppressWarnings("PreferJavaTimeOverload") public class CaffeineSpecGuavaTest extends TestCase { public void testParse_empty() { diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/package-info.java new file mode 100644 index 0000000000..1974f97a7b --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.buffer; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/package-info.java new file mode 100644 index 0000000000..05d7842b0d --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.issues; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/package-info.java new file mode 100644 index 0000000000..6a536374b0 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/stats/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/stats/package-info.java new file mode 100644 index 0000000000..c5d91d8e79 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/stats/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.stats; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContextSubject.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContextSubject.java index a43c9beb99..bfc6f85390 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContextSubject.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContextSubject.java @@ -55,6 +55,7 @@ import com.google.common.truth.FailureMetadata; import com.google.common.truth.StandardSubjectBuilder; import com.google.common.truth.Subject; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * Propositions for {@link CacheContext} subjects. @@ -219,30 +220,37 @@ private StatsSubject(FailureMetadata metadata, CacheContext context) { || (context.executorType() == CacheExecutor.DIRECT); } + @CanIgnoreReturnValue public StatsSubject hits(long count) { return awaitStatistic("hitCount", CacheStats::hitCount, count); } + @CanIgnoreReturnValue public StatsSubject misses(long count) { return awaitStatistic("missCount", CacheStats::missCount, count); } + @CanIgnoreReturnValue public StatsSubject evictions(long count) { return awaitStatistic("evictionCount", CacheStats::evictionCount, count); } + @CanIgnoreReturnValue public StatsSubject evictionWeight(long count) { return awaitStatistic("evictionWeight", CacheStats::evictionWeight, count); } + @CanIgnoreReturnValue public StatsSubject success(long count) { return awaitStatistic("loadSuccessCount", CacheStats::loadSuccessCount, count); } + @CanIgnoreReturnValue public StatsSubject failures(long count) { return awaitStatistic("loadFailureCount", CacheStats::loadFailureCount, count); } + @CanIgnoreReturnValue private StatsSubject awaitStatistic(String label, ToLongFunction supplier, long expectedValue) { if (isDirect) { diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/ExpiryBuilder.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/ExpiryBuilder.java index d794b19d0d..26c753fb42 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/ExpiryBuilder.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/ExpiryBuilder.java @@ -20,6 +20,7 @@ import java.io.Serializable; import com.github.benmanes.caffeine.cache.Expiry; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * A builder for unit test convenience. @@ -45,12 +46,14 @@ public static ExpiryBuilder expiringAfterCreate(long nanos) { } /** Sets the fixed update expiration time. */ + @CanIgnoreReturnValue public ExpiryBuilder expiringAfterUpdate(long nanos) { updateNanos = nanos; return this; } /** Sets the fixed read expiration time. */ + @CanIgnoreReturnValue public ExpiryBuilder expiringAfterRead(long nanos) { readNanos = nanos; return this; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/package-info.java new file mode 100644 index 0000000000..a63f5a0e1c --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.testing; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/acceptance/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/acceptance/package-info.java new file mode 100644 index 0000000000..4462c3fc04 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/acceptance/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.eclipse.acceptance; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/mutable/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/mutable/package-info.java new file mode 100644 index 0000000000..185eb6960e --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/mutable/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.eclipse.mutable; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/package-info.java new file mode 100644 index 0000000000..3dff8e7ad7 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/eclipse/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.eclipse; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/google/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/google/package-info.java new file mode 100644 index 0000000000..3fac419333 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/google/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.google; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/package-info.java new file mode 100644 index 0000000000..21a610d0af --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jsr166; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/package-info.java new file mode 100644 index 0000000000..7b4d6d1976 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.lincheck; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/package-info.java new file mode 100644 index 0000000000..7e490e3225 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/testing/package-info.java b/caffeine/src/test/java/com/github/benmanes/caffeine/testing/package-info.java new file mode 100644 index 0000000000..93eeda5244 --- /dev/null +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/testing/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.testing; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/examples/coalescing-bulkloader/src/main/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java b/examples/coalescing-bulkloader/src/main/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java new file mode 100644 index 0000000000..756be6d1e2 --- /dev/null +++ b/examples/coalescing-bulkloader/src/main/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.examples.coalescing.bulkloader; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/examples/coalescing-bulkloader/src/test/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java b/examples/coalescing-bulkloader/src/test/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java new file mode 100644 index 0000000000..756be6d1e2 --- /dev/null +++ b/examples/coalescing-bulkloader/src/test/java/com/github/benmanes/caffeine/examples/coalescing/bulkloader/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.examples.coalescing.bulkloader; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/WriteBehindCacheWriter.java b/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/WriteBehindCacheWriter.java index bbfe9a1d88..08a31a55c0 100644 --- a/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/WriteBehindCacheWriter.java +++ b/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/WriteBehindCacheWriter.java @@ -27,6 +27,8 @@ import io.reactivex.subjects.PublishSubject; +import com.google.errorprone.annotations.CanIgnoreReturnValue; + /** * This class allows a cache to have "write-behind" semantics. The passed in writeAction will only * be called every 'bufferTime' time with a Map containing the keys and the values that have been @@ -67,18 +69,21 @@ public static final class Builder { * The duration that the calls to the cache should be buffered before calling the * writeAction. */ + @CanIgnoreReturnValue public Builder bufferTime(long duration, TimeUnit unit) { this.bufferTimeNanos = TimeUnit.NANOSECONDS.convert(duration, unit); return this; } /** The callback to perform the writing to the database or repository. */ + @CanIgnoreReturnValue public Builder writeAction(Consumer> writeAction) { this.writeAction = requireNonNull(writeAction); return this; } /** The action that decides which value to take in case a key was updated multiple times. */ + @CanIgnoreReturnValue public Builder coalesce(BinaryOperator coalescer) { this.coalescer = requireNonNull(coalescer); return this; diff --git a/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java b/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java new file mode 100644 index 0000000000..9c09940a81 --- /dev/null +++ b/examples/write-behind-rxjava/src/main/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package src.main.java.com.github.benmanes.caffeine.examples.writebehind.rxjava; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/examples/write-behind-rxjava/src/test/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java b/examples/write-behind-rxjava/src/test/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java new file mode 100644 index 0000000000..4089d1aad0 --- /dev/null +++ b/examples/write-behind-rxjava/src/test/java/com/github/benmanes/caffeine/examples/writebehind/rxjava/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package src.test.java.com.github.benmanes.caffeine.examples.writebehind.rxjava; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/gradle/codeQuality.gradle b/gradle/codeQuality.gradle index 8de4ed1cdc..7444209270 100644 --- a/gradle/codeQuality.gradle +++ b/gradle/codeQuality.gradle @@ -170,7 +170,7 @@ tasks.withType(JavaCompile).configureEach { 'LexicographicalAnnotationListing', 'MissingSummary', 'StaticImport' ] disabledChecks.each { disable(it) } - def errorChecks = [ 'NullAway' ] + def errorChecks = [ 'CanIgnoreReturnValueSuggester', 'NullAway' ] errorChecks.each { error(it) } nullaway { diff --git a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java index f9405bbcfe..7ccdb7c303 100644 --- a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java +++ b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaCache.java @@ -40,6 +40,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ExecutionError; import com.google.common.util.concurrent.UncheckedExecutionException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * A Caffeine-backed cache through a Guava facade. @@ -240,6 +241,7 @@ static final class CacheLoaderException extends RuntimeException { CacheLoaderException(Exception e) { super(e); } + @CanIgnoreReturnValue @SuppressWarnings({"lgtm [java/non-sync-override]", "UnsynchronizedOverridesSynchronized"}) @Override public Throwable fillInStackTrace() { return this; diff --git a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaLoadingCache.java b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaLoadingCache.java index 39fcd276fe..711742ce6a 100644 --- a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaLoadingCache.java +++ b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuavaLoadingCache.java @@ -123,7 +123,7 @@ public V apply(K key) { } @Override - @SuppressWarnings({"CheckReturnValue", "FutureReturnValueIgnored"}) + @SuppressWarnings("FutureReturnValueIgnored") public void refresh(K key) { cache.refresh(key); } diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderFactory.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderFactory.java index a8cdf516dd..1c88a48096 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderFactory.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderFactory.java @@ -29,6 +29,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.util.concurrent.MoreExecutors; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * Helper class for creating {@link CacheBuilder} instances with all combinations of several sets of @@ -36,7 +37,6 @@ * * @author mike nonemacher */ -@SuppressWarnings({"CanIgnoreReturnValueSuggester", "CheckReturnValue"}) class CacheBuilderFactory { // Default values contain only 'null', which means don't call the CacheBuilder method (just give // the CacheBuilder default). @@ -49,42 +49,50 @@ class CacheBuilderFactory { private Set keyStrengths = Sets.newHashSet((Strength) null); private Set valueStrengths = Sets.newHashSet((Strength) null); + @CanIgnoreReturnValue CacheBuilderFactory withConcurrencyLevels(Set concurrencyLevels) { this.concurrencyLevels = Sets.newLinkedHashSet(concurrencyLevels); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withInitialCapacities(Set initialCapacities) { this.initialCapacities = Sets.newLinkedHashSet(initialCapacities); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withMaximumSizes(Set maximumSizes) { this.maximumSizes = Sets.newLinkedHashSet(maximumSizes); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withExpireAfterWrites(Set durations) { this.expireAfterWrites = Sets.newLinkedHashSet(durations); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withExpireAfterAccesses(Set durations) { this.expireAfterAccesses = Sets.newLinkedHashSet(durations); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withRefreshes(Set durations) { this.refreshes = Sets.newLinkedHashSet(durations); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withKeyStrengths(Set keyStrengths) { this.keyStrengths = Sets.newLinkedHashSet(keyStrengths); Preconditions.checkArgument(!this.keyStrengths.contains(Strength.SOFT)); return this; } + @CanIgnoreReturnValue CacheBuilderFactory withValueStrengths(Set valueStrengths) { this.valueStrengths = Sets.newLinkedHashSet(valueStrengths); return this; diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderTest.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderTest.java index 96cd1e7c78..bfa5d8fda6 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderTest.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheBuilderTest.java @@ -61,7 +61,7 @@ */ @GwtCompatible(emulated = true) @SuppressWarnings({"CacheLoaderNull", "CanonicalDuration", - "CheckReturnValue", "PreferJavaTimeOverload", "ThreadPriorityCheck"}) + "PreferJavaTimeOverload", "ThreadPriorityCheck"}) public class CacheBuilderTest extends TestCase { public void testNewBuilder() { diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/LocalLoadingCacheTest.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/LocalLoadingCacheTest.java index 74e91c67d2..6547a0b6e1 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/LocalLoadingCacheTest.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/LocalLoadingCacheTest.java @@ -55,6 +55,7 @@ private Caffeine createCacheBuilder() { // constructor tests + @SuppressWarnings("CheckReturnValue") public void testComputingFunction() { CacheLoader loader = new CacheLoader() { @Override diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/package-info.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/package-info.java new file mode 100644 index 0000000000..ef87390580 --- /dev/null +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.guava.compatibility; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/package-info.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/package-info.java new file mode 100644 index 0000000000..5e7a01be5d --- /dev/null +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.guava; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheFactory.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheFactory.java index cdde01e445..2f22e1245c 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheFactory.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheFactory.java @@ -126,7 +126,6 @@ private static CaffeineConfiguration resolveConfigurationFor( } /** A one-shot builder for creating a cache instance. */ - @SuppressWarnings("CheckReturnValue") private static final class Builder { final Ticker ticker; final String cacheName; diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java index a2fa7a55b2..22f031191b 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java @@ -73,6 +73,7 @@ import com.github.benmanes.caffeine.jcache.management.JmxRegistration; import com.github.benmanes.caffeine.jcache.management.JmxRegistration.MBeanType; import com.github.benmanes.caffeine.jcache.processor.EntryProcessorEntry; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * An implementation of JSR-107 {@link Cache} backed by a Caffeine cache. @@ -279,7 +280,6 @@ public void loadAll(Set keys, boolean replaceExistingValues, } /** Performs the bulk load where the existing entries are replaced. */ - @SuppressWarnings("CheckReturnValue") private void loadAllAndReplaceExisting(Set keys) { Map loaded = cacheLoader.orElseThrow().loadAll(keys); for (var entry : loaded.entrySet()) { @@ -288,7 +288,6 @@ private void loadAllAndReplaceExisting(Set keys) { } /** Performs the bulk load where the existing entries are retained. */ - @SuppressWarnings("CheckReturnValue") private void loadAllAndKeepExisting(Set keys) { List keysToLoad = keys.stream() .filter(key -> !cache.asMap().containsKey(key)) @@ -351,6 +350,7 @@ public void put(K key, V value) { * @param publishToWriter if the writer should be notified * @return the old value */ + @CanIgnoreReturnValue protected PutResult putNoCopyOrAwait(K key, V value, boolean publishToWriter) { requireNonNull(key); requireNonNull(value); @@ -444,6 +444,7 @@ public void putAll(Map map) { } @Override + @CanIgnoreReturnValue public boolean putIfAbsent(K key, V value) { requireNotClosed(); requireNonNull(value); @@ -474,6 +475,7 @@ public boolean putIfAbsent(K key, V value) { * @param publishToWriter if the writer should be notified * @return if the mapping was successful */ + @CanIgnoreReturnValue private boolean putIfAbsentNoAwait(K key, V value, boolean publishToWriter) { boolean[] absent = { false }; cache.asMap().compute(copyOf(key), (k, expirable) -> { @@ -507,6 +509,7 @@ private boolean putIfAbsentNoAwait(K key, V value, boolean publishToWriter) { } @Override + @CanIgnoreReturnValue public boolean remove(K key) { requireNotClosed(); requireNonNull(key); @@ -552,6 +555,7 @@ private V removeNoCopyOrAwait(K key) { } @Override + @CanIgnoreReturnValue public boolean remove(K key, V oldValue) { requireNotClosed(); requireNonNull(key); @@ -619,6 +623,7 @@ public V getAndRemove(K key) { } @Override + @CanIgnoreReturnValue public boolean replace(K key, V oldValue, V newValue) { requireNotClosed(); requireNonNull(oldValue); @@ -671,6 +676,7 @@ public boolean replace(K key, V oldValue, V newValue) { } @Override + @CanIgnoreReturnValue public boolean replace(K key, V value) { requireNotClosed(); boolean statsEnabled = statistics.isEnabled(); @@ -1238,7 +1244,6 @@ public Cache.Entry next() { } @Override - @SuppressWarnings("CheckReturnValue") public void remove() { if (current == null) { throw new IllegalStateException(); diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurationTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurationTest.java index 2b8c801f76..718d10268b 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurationTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/TypesafeConfigurationTest.java @@ -72,7 +72,6 @@ public void illegalPath() { assertThat(TypesafeConfigurator.from(ConfigFactory.load(), "#")).isEmpty(); } - @SuppressWarnings("CheckReturnValue") @Test(expectedExceptions = IllegalStateException.class) public void invalidCache() { TypesafeConfigurator.from(ConfigFactory.load(), "invalid-cache"); diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/package-info.java new file mode 100644 index 0000000000..37d466184a --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/configuration/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.configuration; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/JavaSerializationCopierTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/JavaSerializationCopierTest.java index 55353d06ae..08cd70b43e 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/JavaSerializationCopierTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/JavaSerializationCopierTest.java @@ -44,7 +44,6 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings("CheckReturnValue") public final class JavaSerializationCopierTest { @Test(dataProvider = "nullArgs", expectedExceptions = NullPointerException.class) diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/package-info.java new file mode 100644 index 0000000000..4b6aad596e --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/copy/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.copy; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/event/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/event/package-info.java new file mode 100644 index 0000000000..9b3c6707d8 --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/event/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.event; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/expiry/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/expiry/package-info.java new file mode 100644 index 0000000000..31d27656a9 --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/expiry/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.expiry; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/package-info.java new file mode 100644 index 0000000000..785bbd147e --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/integration/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.integration; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/package-info.java new file mode 100644 index 0000000000..d3d6c07883 --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.management; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/package-info.java new file mode 100644 index 0000000000..cfeead53ba --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/processor/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/processor/package-info.java new file mode 100644 index 0000000000..59e0c1b095 --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/processor/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.processor; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/size/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/size/package-info.java new file mode 100644 index 0000000000..9bddc5d7f6 --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/size/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.size; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/package-info.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/package-info.java new file mode 100644 index 0000000000..dcaba8edba --- /dev/null +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/spi/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.jcache.spi; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/build.gradle b/simulator/build.gradle index 549652ca8b..de05e3f686 100644 --- a/simulator/build.gradle +++ b/simulator/build.gradle @@ -65,7 +65,6 @@ tasks.named('sourcesJar').configure { tasks.withType(JavaCompile).configureEach { options.errorprone { - disable('CanIgnoreReturnValueSuggester') nullaway.disable() } } diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/CountMin4.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/CountMin4.java index c50d727f6a..8f4a783711 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/CountMin4.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/CountMin4.java @@ -20,6 +20,7 @@ import com.github.benmanes.caffeine.cache.simulator.BasicSettings; import com.github.benmanes.caffeine.cache.simulator.admission.Frequency; import com.google.common.math.IntMath; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.typesafe.config.Config; /** @@ -126,7 +127,6 @@ void regularIncrement(long e) { } /** Increments the associated counters that are at the observed minimum. */ - @SuppressWarnings("CheckReturnValue") void conservativeIncrement(long e) { int hash = spread(Long.hashCode(e)); int start = (hash & 3) << 2; @@ -164,6 +164,7 @@ void conservativeIncrement(long e) { * @param step the increase amount * @return if incremented */ + @CanIgnoreReturnValue boolean incrementAt(int i, int j, long step) { int offset = j << 2; long mask = (0xfL << offset); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/address/penalties/package-info.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/address/penalties/package-info.java new file mode 100644 index 0000000000..39c149fec8 --- /dev/null +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/address/penalties/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.parser.address.penalties; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyStats.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyStats.java index 7febaa3ddf..ac9456b6a5 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyStats.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyStats.java @@ -36,6 +36,7 @@ import com.google.auto.value.AutoValue.CopyAnnotations; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * Statistics gathered by a policy execution. A policy can extend this class as a convenient way to @@ -318,6 +319,7 @@ public abstract static class Builder { public abstract ImmutableSet.Builder characteristicsBuilder(); public abstract Metric build(); + @CanIgnoreReturnValue public final Builder addCharacteristic(Characteristic characteristic) { characteristicsBuilder().add(characteristic); return this; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java index 75b2989450..f4bec62a41 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java @@ -22,6 +22,7 @@ import com.github.benmanes.caffeine.cache.simulator.policy.Policy.PolicySpec; import com.github.benmanes.caffeine.cache.simulator.policy.PolicyStats; import com.google.common.base.MoreObjects; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.typesafe.config.Config; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -197,7 +198,6 @@ private void onNonResidentMiss(Node node) { evict(); } - @SuppressWarnings("CheckReturnValue") private void evict() { policyStats.recordEviction(); while (maxSize < sizeCold + sizeHot) { @@ -272,6 +272,7 @@ private void scanCold() { // ScanHot demotes a hot entry between the oldest hot entry's epoch and the given epoch. // If the demotion was successful it returns true, otherwise it returns false. + @CanIgnoreReturnValue private boolean scanHot(long epoch) { for (Node victim = headHot.prev; victim.epoch <= epoch; victim = headHot.prev) { policyStats.recordOperation(); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CaffeinePolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CaffeinePolicy.java index ba4d1ada2b..87ded91014 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CaffeinePolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/product/CaffeinePolicy.java @@ -40,7 +40,6 @@ public final class CaffeinePolicy implements Policy { private final Cache cache; private final PolicyStats policyStats; - @SuppressWarnings("CheckReturnValue") public CaffeinePolicy(Config config, Set characteristics) { policyStats = new PolicyStats(name()); BasicSettings settings = new BasicSettings(config); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/gradient/package-info.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/gradient/package-info.java new file mode 100644 index 0000000000..8d78ebb0ed --- /dev/null +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/gradient/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.gradient; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/hill/package-info.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/hill/package-info.java new file mode 100644 index 0000000000..9b128a21f5 --- /dev/null +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/hill/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.hill; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/inference/package-info.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/inference/package-info.java new file mode 100644 index 0000000000..f84a278b5f --- /dev/null +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/inference/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.inference; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/sim/package-info.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/sim/package-info.java new file mode 100644 index 0000000000..04af759b70 --- /dev/null +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/climbing/sim/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.policy.sketch.climbing.sim; + +import com.google.errorprone.annotations.CheckReturnValue; diff --git a/simulator/src/test/java/com/github/benmanes/caffeine/cache/simulator/admission/bloom/package-info.java b/simulator/src/test/java/com/github/benmanes/caffeine/cache/simulator/admission/bloom/package-info.java new file mode 100644 index 0000000000..26ded75d72 --- /dev/null +++ b/simulator/src/test/java/com/github/benmanes/caffeine/cache/simulator/admission/bloom/package-info.java @@ -0,0 +1,4 @@ +@CheckReturnValue +package com.github.benmanes.caffeine.cache.simulator.admission.bloom; + +import com.google.errorprone.annotations.CheckReturnValue;