diff --git a/caffeine/build.gradle.kts b/caffeine/build.gradle.kts index 8e3f915839..f6382ec08b 100644 --- a/caffeine/build.gradle.kts +++ b/caffeine/build.gradle.kts @@ -83,6 +83,7 @@ val compileCodeGenJava by tasks.existing(JavaCompile::class) { options.errorprone { disable("FieldMissingNullable") disable("MissingOverride") + disable("MemberName") disable("Varifier") nullaway.disable() } @@ -129,8 +130,6 @@ tasks.named("compileJava").configure { tasks.named("compileTestJava").configure { dependsOn(tasks.jar, compileCodeGenJava) options.errorprone { - disable("MemberName") - disable("SystemOut") disable("Varifier") disable("Var") } @@ -138,8 +137,6 @@ tasks.named("compileTestJava").configure { tasks.named("compileJmhJava").configure { options.errorprone { - disable("MemberName") - disable("SystemOut") disable("Varifier") disable("Var") } diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/DelegationBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/DelegationBenchmark.java index 669ca0f4e5..15dc7d81e1 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/DelegationBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/DelegationBenchmark.java @@ -33,7 +33,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) -@SuppressWarnings("PMD.MethodNamingConventions") +@SuppressWarnings({"MemberName", "PMD.MethodNamingConventions"}) public class DelegationBenchmark { private static final int SIZE = (2 << 14); private static final int MASK = SIZE - 1; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/FactoryBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/FactoryBenchmark.java index dcefb62c08..2781547ddf 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/FactoryBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/FactoryBenchmark.java @@ -36,7 +36,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) -@SuppressWarnings("PMD.MethodNamingConventions") +@SuppressWarnings({"MemberName", "PMD.MethodNamingConventions"}) public class FactoryBenchmark { private final ReflectionFactory reflectionFactory = new ReflectionFactory(); private final MethodHandleFactory methodHandleFactory = new MethodHandleFactory(); diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/SlotLookupBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/SlotLookupBenchmark.java index 6ebe6f915d..9313bbd6d6 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/SlotLookupBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/SlotLookupBenchmark.java @@ -48,7 +48,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) -@SuppressWarnings("PMD.MethodNamingConventions") +@SuppressWarnings({"MemberName", "PMD.MethodNamingConventions"}) public class SlotLookupBenchmark { static final int SPARSE_SIZE = 2 << 14; static final int ARENA_SIZE = 2 << 6; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/TimeBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/TimeBenchmark.java index b2ad1acdde..e46b38f9d9 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/TimeBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/TimeBenchmark.java @@ -21,7 +21,7 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings("PMD.MethodNamingConventions") +@SuppressWarnings({"MemberName", "PMD.MethodNamingConventions"}) public class TimeBenchmark { @Benchmark @Threads(1) diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/BuilderBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/BuilderBenchmark.java index ef632be47b..74dae640ae 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/BuilderBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/BuilderBenchmark.java @@ -37,6 +37,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) +@SuppressWarnings("MemberName") public class BuilderBenchmark { @Param BuilderType type; Supplier builder; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java index f2b84a17dd..c58dec70c8 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/CacheType.java @@ -42,6 +42,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public enum CacheType { /* --------------- Unbounded --------------- */ diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/ComputeBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/ComputeBenchmark.java index 99c4910997..8f61682d4c 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/ComputeBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/ComputeBenchmark.java @@ -37,7 +37,8 @@ * @author ben.manes@gmail.com (Ben Manes) */ @State(Scope.Benchmark) -@SuppressWarnings({"LexicographicalAnnotationAttributeListing", "PMD.MethodNamingConventions"}) +@SuppressWarnings({"LexicographicalAnnotationAttributeListing", + "MemberName", "PMD.MethodNamingConventions"}) public class ComputeBenchmark { static final int SIZE = (2 << 14); static final int MASK = SIZE - 1; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java index 2cf94f5f9c..92a61396a6 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/GetPutBenchmark.java @@ -42,7 +42,7 @@ */ @State(Scope.Group) @SuppressWarnings({"CanonicalAnnotationSyntax", "LexicographicalAnnotationAttributeListing", - "PMD.JUnit4TestShouldUseAfterAnnotation", "PMD.MethodNamingConventions"}) + "MemberName", "PMD.JUnit4TestShouldUseAfterAnnotation", "PMD.MethodNamingConventions"}) public class GetPutBenchmark { private static final int SIZE = (2 << 14); private static final int MASK = SIZE - 1; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/MemoryBenchmark.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/MemoryBenchmark.java index a3ef9b26b9..e9e8fd302f 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/MemoryBenchmark.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/MemoryBenchmark.java @@ -44,7 +44,8 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings({"LexicographicalAnnotationAttributeListing", "PMD.MethodNamingConventions"}) +@SuppressWarnings({"LexicographicalAnnotationAttributeListing", + "MemberName", "PMD.MethodNamingConventions", "SystemOut"}) public final class MemoryBenchmark { // The number of entries added to minimize skew due to non-entry factors static final int FUZZY_SIZE = 25_000; diff --git a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SketchType.java b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SketchType.java index 08b725bbce..271e1c9f55 100644 --- a/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SketchType.java +++ b/caffeine/src/jmh/java/com/github/benmanes/caffeine/cache/SketchType.java @@ -23,6 +23,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public enum SketchType { Flat { @Override public TinyLfuSketch create(long estimatedSize) { 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 265a68f386..bebf0a6548 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 @@ -46,7 +46,7 @@ public final void run() { protected abstract void profile(); - @SuppressWarnings("FutureReturnValueIgnored") + @SuppressWarnings({"FutureReturnValueIgnored", "SystemOut"}) private void scheduleStatusTask() { var stopwatch = Stopwatch.createStarted(); Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(() -> { diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java index 6929b104b4..50c8fab312 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedBuffer.java @@ -121,7 +121,7 @@ public long writes() { } /** The namespace for field padding through inheritance. */ -@SuppressWarnings("MultiVariableDeclaration") +@SuppressWarnings({"MemberName", "MultiVariableDeclaration"}) final class BBHeader { private BBHeader() {} diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java index 8b4ddcbd01..225b412418 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java @@ -4594,7 +4594,7 @@ private Object writeReplace() { } /** The namespace for field padding through inheritance. */ -@SuppressWarnings("MultiVariableDeclaration") +@SuppressWarnings({"MemberName", "MultiVariableDeclaration"}) final class BLCHeader { private BLCHeader() {} 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 60c723fd75..12296fc8db 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 @@ -242,6 +242,19 @@ static int calculateHashMapCapacity(Iterable iterable) { : DEFAULT_INITIAL_CAPACITY; } + /** + * Returns the number of nanoseconds of the given duration without throwing or overflowing. + *

+ * Instead of throwing {@link ArithmeticException}, this method silently saturates to either + * {@link Long#MAX_VALUE} or {@link Long#MIN_VALUE}. This behavior can be useful when decomposing + * a duration in order to call a legacy API which requires a {@code long, TimeUnit} pair. + */ + static long toNanosSaturated(Duration duration) { + return duration.isNegative() + ? (duration.compareTo(MIN_DURATION) <= 0) ? Long.MIN_VALUE : duration.toNanos() + : (duration.compareTo(MAX_DURATION) >= 0) ? Long.MAX_VALUE : duration.toNanos(); + } + /** * Constructs a new {@code Caffeine} instance with default settings, including strong keys, strong * values, and no automatic eviction of any kind. @@ -1183,19 +1196,6 @@ void requireWeightWithWeigher() { } } - /** - * Returns the number of nanoseconds of the given duration without throwing or overflowing. - *

- * Instead of throwing {@link ArithmeticException}, this method silently saturates to either - * {@link Long#MAX_VALUE} or {@link Long#MIN_VALUE}. This behavior can be useful when decomposing - * a duration in order to call a legacy API which requires a {@code long, TimeUnit} pair. - */ - static long toNanosSaturated(Duration duration) { - return duration.isNegative() - ? (duration.compareTo(MIN_DURATION) <= 0) ? Long.MIN_VALUE : duration.toNanos() - : (duration.compareTo(MAX_DURATION) >= 0) ? Long.MAX_VALUE : duration.toNanos(); - } - /** * Returns a string representation for this Caffeine instance. The exact form of the returned * string is not specified. diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/OSGiTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/OSGiTest.java index 3168a7ba2e..88ef265f0d 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/OSGiTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/OSGiTest.java @@ -35,6 +35,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @RunWith(PaxExam.class) +@SuppressWarnings("MemberName") @ExamReactorStrategy(PerMethod.class) public final class OSGiTest { 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 684bcf70f6..b5aca04003 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 @@ -325,6 +325,7 @@ public void testParse_unknownKey() { } // Allowed by Caffeine + @SuppressWarnings("MemberName") public void disabled_testParse_extraCommaIsInvalid() { assertThrows(IllegalArgumentException.class, () -> parse("weakKeys,")); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/Stresser.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/Stresser.java index c3d6a635a7..f617d5d2ca 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/Stresser.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/Stresser.java @@ -115,6 +115,7 @@ private void execute() { }); } + @SuppressWarnings("SystemOut") private void status() { var evictionLock = local.evictionLock; int pendingWrites; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java index 9e185ad207..6bd2c460d2 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/TimerWheelTest.java @@ -561,6 +561,7 @@ private List snapshot(boolean ascending) { return snapshot; } + @SuppressWarnings("SystemOut") private void printTimerWheel() { var builder = new StringBuilder(); for (int i = 0; i < timerWheel.wheel.length; i++) { diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/BufferType.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/BufferType.java index 61f2de9473..cee61cca28 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/BufferType.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/buffer/BufferType.java @@ -22,7 +22,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings("ImmutableEnumChecker") +@SuppressWarnings({"ImmutableEnumChecker", "MemberName"}) public enum BufferType { Ticket(TicketBuffer::new), FastFlow(FastFlowBuffer::new), diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/HashClashTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/HashClashTest.java index dc99bea10c..bd83ade938 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/HashClashTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/HashClashTest.java @@ -84,6 +84,7 @@ public void testCache(Cache cache, CacheContext context) { assertThat(cache.stats().hitRate()).isGreaterThan(0.99d); } + @SuppressWarnings("SystemOut") static void printStats(Cache cache) { if (debug) { System.out.printf("size %,d requests %,d hit ratio %f%n", @@ -91,6 +92,7 @@ static void printStats(Cache cache) { } } + @SuppressWarnings("SystemOut") static void printKeys(Cache cache) { if (debug) { Set keys = cache.policy().eviction() diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Issue30Test.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Issue30Test.java index cd18cebe22..b290ccc5f8 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Issue30Test.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Issue30Test.java @@ -167,7 +167,7 @@ public CompletableFuture asyncLoad(String key, Executor executor) { return CompletableFuture.completedFuture(source.get(key)); } - @SuppressWarnings("TimeZoneUsage") + @SuppressWarnings({"SystemOut", "TimeZoneUsage"}) private void reportCacheMiss(String key) { Instant now = Instant.now(); Instant last = lastLoad.get(key); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Solr10141Test.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Solr10141Test.java index c235a2aa6e..d2d20d822c 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Solr10141Test.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/issues/Solr10141Test.java @@ -17,6 +17,7 @@ import static com.github.benmanes.caffeine.testing.Awaits.await; import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; import static java.util.Locale.US; import java.util.Random; @@ -30,6 +31,7 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.RemovalListener; import com.github.benmanes.caffeine.testing.ConcurrentTestHarness; +import com.google.common.base.MoreObjects; /** * SOLR-10141: Removal listener notified with stale value @@ -112,8 +114,7 @@ void test(Random r) { } if ((v == null) || (updateAnyway && r.nextBoolean())) { - v = new Val(); - v.key = k; + v = new Val(k); cache.put(k, v); inserts.incrementAndGet(); } @@ -128,11 +129,11 @@ void test(Random r) { await().until(() -> (inserts.get() - removals.get()) == cache.estimatedSize()); - System.out.printf(US, "Done!%n" - + "entries=%,d inserts=%,d removals=%,d hits=%,d maxEntries=%,d maxObservedSize=%,d%n", - cache.estimatedSize(), inserts.get(), removals.get(), - hits.get(), maxEntries, maxObservedSize.get()); - assertThat(failed).isEmpty(); + var message = String.format(US, + "entries=%,d inserts=%,d removals=%,d hits=%,d maxEntries=%,d maxObservedSize=%,d%n", + cache.estimatedSize(), inserts.get(), removals.get(), hits.get(), maxEntries, + maxObservedSize.get()); + assertWithMessage(message).that(failed).isEmpty(); } @Test @@ -176,8 +177,7 @@ void test(Random r) { } if ((v == null) || (updateAnyway && r.nextBoolean())) { - v = new Val(); - v.key = k; + v = new Val(k); cache.put(k, v); inserts.incrementAndGet(); } @@ -193,8 +193,19 @@ void test(Random r) { assertThat(failed).isEmpty(); } - static class Val { - long key; - AtomicBoolean live = new AtomicBoolean(true); + static final class Val { + final AtomicBoolean live; + final long key; + + Val(long key) { + this.live = new AtomicBoolean(true); + this.key = key; + } + @Override public String toString() { + return MoreObjects.toStringHelper(this) + .add("key", key) + .add("live", live.get()) + .toString(); + } } } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java index b94d036fae..69f6cfa86c 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheSpec.java @@ -67,8 +67,8 @@ * * @author ben.manes@gmail.com (Ben Manes) */ -@SuppressWarnings("ImmutableEnumChecker") @Target(METHOD) @Retention(RUNTIME) +@SuppressWarnings({"ImmutableEnumChecker", "MemberName"}) public @interface CacheSpec { /* --------------- Compute --------------- */ diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java b/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java index 158c31f696..e42a1e9d0f 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/fuzz/CaffeineSpecFuzzer.java @@ -27,10 +27,10 @@ public final class CaffeineSpecFuzzer { // These tests require the environment variable JAZZER_FUZZ=1 to try new input arguments @FuzzTest(maxDuration = "5m") - @SuppressWarnings({"CheckReturnValue", "PMD.EmptyCatchBlock"}) + @SuppressWarnings("CheckReturnValue") public void parse(FuzzedDataProvider data) { try { CaffeineSpec.parse(data.consumeRemainingAsString()); - } catch (IllegalArgumentException e) { /* ignored */ } + } catch (IllegalArgumentException expected) { /* ignored */ } } } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/Collection8Test.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/Collection8Test.java index f40fdcb428..9dbab2ff63 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/Collection8Test.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/Collection8Test.java @@ -53,9 +53,9 @@ */ @SuppressWarnings({"CatchAndPrintStackTrace", "CollectionAddAllToCollectionBlock", "CollectionForEach", "CollectionIsEmpty", "CollectionToArray", "CollectorMutability", - "LabelledBreakTarget", "MethodReferenceUsage", "MissingDefault", "MissingFail", - "MultiVariableDeclaration", "rawtypes", "ReturnValueIgnored", "try", "unchecked", - "UnnecessaryFinal", "UnnecessaryParentheses", "YodaCondition"}) + "EmptyCatch", "LabelledBreakTarget", "MemberName", "MethodReferenceUsage", "MissingDefault", + "MissingFail", "MultiVariableDeclaration", "rawtypes", "ReturnValueIgnored", "SystemOut", + "try", "unchecked", "UnnecessaryFinal", "UnnecessaryParentheses", "YodaCondition"}) public class Collection8Test extends JSR166TestCase { final CollectionImplementation impl; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMap8Test.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMap8Test.java index ed1637d15b..84bc3b750e 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMap8Test.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMap8Test.java @@ -30,7 +30,7 @@ import junit.framework.Test; import junit.framework.TestSuite; -@SuppressWarnings({"IdentityConversion", "PreferredInterfaceType", +@SuppressWarnings({"EmptyCatch", "IdentityConversion", "PreferredInterfaceType", "rawtypes", "try", "unchecked", "UnnecessaryFinal"}) public class ConcurrentHashMap8Test extends JSR166TestCase { public static void main(String[] args) { diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java index 5ca00b771b..319f31ede8 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/ConcurrentHashMapTest.java @@ -24,8 +24,9 @@ import junit.framework.Test; -@SuppressWarnings({"ForEachIterable", "ModifyCollectionInEnhancedForLoop", "PreferredInterfaceType", - "rawtypes", "ReturnValueIgnored", "unchecked", "UnnecessaryFinal", "UnnecessaryParentheses"}) +@SuppressWarnings({"EmptyCatch", "ForEachIterable", "MemberName", + "ModifyCollectionInEnhancedForLoop", "PreferredInterfaceType", "rawtypes", + "ReturnValueIgnored", "unchecked", "UnnecessaryFinal", "UnnecessaryParentheses"}) public class ConcurrentHashMapTest extends JSR166TestCase { public static void main(String[] args) { main(suite()); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java index a7673cfce0..615cc254e2 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/jsr166/JSR166TestCase.java @@ -194,10 +194,10 @@ * */ @SuppressWarnings({"AnnotateFormatMethod", "ClassEscapesDefinedScope", "CollectionToArray", - "ConstantField", "EqualsIncompatibleType", "FunctionalInterfaceClash", + "ConstantField", "EmptyCatch", "EqualsIncompatibleType", "FunctionalInterfaceClash", "InterruptedExceptionSwallowed", "JavaUtilDate", "JUnit3FloatingPointComparisonWithoutDelta", - "NonFinalStaticField", "NumericEquality", "rawtypes", "ReferenceEquality", - "RethrowReflectiveOperationExceptionAsLinkageError", "serial", "SwitchDefault", + "MemberName", "NonFinalStaticField", "NumericEquality", "rawtypes", "ReferenceEquality", + "RethrowReflectiveOperationExceptionAsLinkageError", "serial", "SwitchDefault", "SystemOut", "ThreadPriorityCheck", "try", "unchecked", "UndefinedEquals", "UnnecessaryFinal"}) public class JSR166TestCase extends TestCase { // private static final boolean useSecurityManager = diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/AbstractLincheckCacheTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/AbstractLincheckCacheTest.java index 4aefbfa0bb..ef523ab511 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/AbstractLincheckCacheTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/lincheck/AbstractLincheckCacheTest.java @@ -41,7 +41,7 @@ */ @Param(name = "key", gen = IntGen.class, conf = "1:5") @Param(name = "value", gen = IntGen.class, conf = "1:10") -@SuppressWarnings("PMD.AbstractClassWithoutAbstractMethod") +@SuppressWarnings({"MemberName", "PMD.AbstractClassWithoutAbstractMethod"}) public abstract class AbstractLincheckCacheTest { private final LoadingCache cache; diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/testing/Threads.java b/caffeine/src/test/java/com/github/benmanes/caffeine/testing/Threads.java index 891087f1d4..1eef57024d 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/testing/Threads.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/testing/Threads.java @@ -68,8 +68,8 @@ public static void runTest(A collection, ImmutableList> o public static void executeWithTimeOut(Queue failures, Callable task) { try { var future = executor.submit(task); - long timeNS = future.get(TIMEOUT, TimeUnit.SECONDS); - logger.debug("\nExecuted in {} second(s)", TimeUnit.NANOSECONDS.toSeconds(timeNS)); + long nanos = future.get(TIMEOUT, TimeUnit.SECONDS); + logger.debug("\nExecuted in {} second(s)", TimeUnit.NANOSECONDS.toSeconds(nanos)); } catch (ExecutionException e) { fail("Exception during test: " + e, e); } catch (TimeoutException e) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2303e8a6d7..2331da8f87 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ coveralls = "2.12.2" dependency-check = "10.0.4" eclipse-collections = "12.0.0.M3" ehcache3 = "3.10.8" -errorprone = "2.32.0" +errorprone = "2.33.0" errorprone-plugin = "4.0.1" errorprone-support = "0.18.0" expiring-map = "0.5.11" @@ -41,7 +41,7 @@ hamcrest = "3.0" hazelcast = "5.3.7" httpclient = "4.5.14" idea = "1.1.9" -jackrabbit = "1.68.0" +jackrabbit = "1.70.0" jackson = "2.18.0" jacoco = "0.8.12" jakarta-inject = "2.0.1" @@ -66,7 +66,7 @@ junit5 = "5.11.1" jvm-dependency-conflict-resolution = "2.1.2" kotlin = "2.0.20" lincheck = "2.34" -mockito = "5.14.0" +mockito = "5.14.1" nexus-publish = "2.0.0" nullaway = "0.11.3" nullaway-plugin = "2.0.0" diff --git a/gradle/plugins/build.gradle.kts b/gradle/plugins/build.gradle.kts index 83ef0690e1..eba4ab1f42 100644 --- a/gradle/plugins/build.gradle.kts +++ b/gradle/plugins/build.gradle.kts @@ -90,6 +90,6 @@ fun setProjectEncoding() { } } -if (System.getenv("CI").isNullOrEmpty()) { +if (!providers.environmentVariable("CI").isPresent) { setProjectEncoding() } diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java index 5ae5f74272..f244daa003 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/OSGiTest.java @@ -37,6 +37,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @RunWith(PaxExam.class) +@SuppressWarnings("MemberName") @ExamReactorStrategy(PerMethod.class) public final class OSGiTest { 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 274447fd7e..c2ff09e997 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 @@ -448,7 +448,7 @@ public void testRemovalNotification_clear_basher() throws InterruptedException { * (removed because of size limits or expiration) trigger appropriate removal notifications. */ @GwtIncompatible("QueuingRemovalListener") - @SuppressWarnings("FutureReturnValueIgnored") + @SuppressWarnings({"EmptyCatch", "FutureReturnValueIgnored"}) public void testRemovalNotification_get_basher() throws InterruptedException { int nTasks = 1000; int nThreads = 100; diff --git a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheLoadingTest.java b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheLoadingTest.java index f85378a996..a54848a257 100644 --- a/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheLoadingTest.java +++ b/guava/src/test/java/com/github/benmanes/caffeine/guava/compatibility/CacheLoadingTest.java @@ -1819,11 +1819,7 @@ private static void testConcurrentLoadingUncheckedException( } // subsequent calls should call the loader again, not get the old exception - try { - cache.getUnchecked("bar"); - fail(); - } catch (UncheckedExecutionException expected) { - } + assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked("bar")); assertEquals(count + 1, callCount.get()); } @@ -1867,11 +1863,7 @@ private static void testConcurrentLoadingCheckedException( } // subsequent calls should call the loader again, not get the old exception - try { - cache.getUnchecked("bar"); - fail(); - } catch (UncheckedExecutionException expected) { - } + assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked("bar")); assertEquals(count + 1, callCount.get()); } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheMXBean.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheMXBean.java index ecd9da96ca..8620f0b03c 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheMXBean.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheMXBean.java @@ -26,6 +26,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public final class JCacheMXBean implements CacheMXBean { private final Cache cache; diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBean.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBean.java index f637c6dccb..859dbc36fd 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBean.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBean.java @@ -27,6 +27,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public final class JCacheStatisticsMXBean implements CacheStatisticsMXBean { private final LongAdder puts = new LongAdder(); private final LongAdder hits = new LongAdder(); diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/OSGiTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/OSGiTest.java index a819931db6..1b9b6ec128 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/OSGiTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/OSGiTest.java @@ -41,6 +41,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ @RunWith(PaxExam.class) +@SuppressWarnings("MemberName") @ExamReactorStrategy(PerMethod.class) public final class OSGiTest { private static final String PROVIDER_NAME = diff --git a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBeanTest.java b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBeanTest.java index 23a0cf098b..5a639aaecc 100644 --- a/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBeanTest.java +++ b/jcache/src/test/java/com/github/benmanes/caffeine/jcache/management/JCacheStatisticsMXBeanTest.java @@ -22,6 +22,7 @@ /** * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public final class JCacheStatisticsMXBeanTest { @Test diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/glcache/GLCacheTraceReader.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/glcache/GLCacheTraceReader.java index 2d06e699af..e0011974e5 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/glcache/GLCacheTraceReader.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/glcache/GLCacheTraceReader.java @@ -31,6 +31,7 @@ * * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") public final class GLCacheTraceReader extends BinaryTraceReader { public GLCacheTraceReader(String filePath) { diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java index b7d0bbce41..a593aac63f 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java @@ -44,6 +44,7 @@ * @author himelbrand@gmail.com (Omri Himelbrand) * @author ben.manes@gmail.com (Ben Manes) */ +@SuppressWarnings("MemberName") @PolicySpec(name = "greedy-dual.GDWheel", characteristics = WEIGHTED) public final class GDWheelPolicy implements Policy { private final Long2ObjectMap data;