From 8186ff8b59e1f041ba1993b03eda8a5adcab43af Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Thu, 7 Nov 2024 12:07:44 -0800 Subject: [PATCH] fix warnings flagged by ArgumentSelectionDefectChecker https://github.com/ben-manes/caffeine/commit/8b835c96ae6b1ea64b0706bc0484291c0c6f93f3#diff-1c22230aca4b1be3a2e99f27b86a721ec1feebeb7f800953335f1c22c4b84841R122 --- caffeine/build.gradle.kts | 18 +++++++++++------- .../cache/LocalCacheFactoryGenerator.java | 2 +- .../caffeine/cache/NodeFactoryGenerator.java | 2 +- .../caffeine/cache/LocalAsyncCache.java | 2 +- .../lifecycle/java-library.caffeine.gradle.kts | 3 ++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/caffeine/build.gradle.kts b/caffeine/build.gradle.kts index 1441c07949..33c99a2d34 100644 --- a/caffeine/build.gradle.kts +++ b/caffeine/build.gradle.kts @@ -83,14 +83,18 @@ dependencies { val compileCodeGenJava by tasks.existing(JavaCompile::class) { classpath = sourceSets["main"].runtimeClasspath + sourceSets["main"].output dependsOn(tasks.compileJava) - options.isDebug = false - options.errorprone { - disable("FieldMissingNullable") - disable("MissingOverride") - disable("MemberName") - disable("Varifier") - nullaway.disable() + options.apply { + compilerArgs.remove("-parameters") + isDebug = false + + errorprone { + disable("FieldMissingNullable") + disable("MissingOverride") + disable("MemberName") + disable("Varifier") + nullaway.disable() + } } } diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java index ec02741647..24b398fe5f 100644 --- a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/LocalCacheFactoryGenerator.java @@ -117,7 +117,7 @@ private void reformat() throws IOException { .filter(path -> path.endsWith(".java")) .collect(toImmutableList()); ToolProvider.findFirst("google-java-format").ifPresent(formatter -> { - int result = formatter.run(System.err, System.out, + int result = formatter.run(System.out, System.err, Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new)); checkState(result == 0, "Java formatting failed with %s exit code", result); }); diff --git a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java index 65d5714197..89a53b7026 100644 --- a/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java +++ b/caffeine/src/javaPoet/java/com/github/benmanes/caffeine/cache/NodeFactoryGenerator.java @@ -119,7 +119,7 @@ private void reformat() throws IOException { .filter(path -> path.endsWith(".java")) .collect(toImmutableList()); ToolProvider.findFirst("google-java-format").ifPresent(formatter -> { - int result = formatter.run(System.err, System.out, + int result = formatter.run(System.out, System.err, Stream.concat(Stream.of("-i"), files.stream()).toArray(String[]::new)); checkState(result == 0, "Java formatting failed with %s exit code", result); }); diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java index bb229747aa..7b9237f41c 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java @@ -200,7 +200,7 @@ default void handleCompletion(K key, CompletableFuture valueFuture, long startTime, boolean recordMiss) { var completed = new AtomicBoolean(); valueFuture.whenComplete((value, error) -> { - if (!completed.compareAndSet(false, true)) { + if (!completed.compareAndSet(/* expectedValue= */ false, /* newValue= */ true)) { // Ignore multiple invocations due to ForkJoinPool retrying on delays return; } diff --git a/gradle/plugins/src/main/kotlin/lifecycle/java-library.caffeine.gradle.kts b/gradle/plugins/src/main/kotlin/lifecycle/java-library.caffeine.gradle.kts index 36a0ee9b47..d1052c1723 100644 --- a/gradle/plugins/src/main/kotlin/lifecycle/java-library.caffeine.gradle.kts +++ b/gradle/plugins/src/main/kotlin/lifecycle/java-library.caffeine.gradle.kts @@ -38,7 +38,8 @@ tasks.withType().configureEach { } options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-auxiliaryclass", "-Xlint:-classfile", - "-Xlint:-exports", "-Xlint:-processing", "-Xlint:-removal", "-Xlint:-requires-automatic")) + "-Xlint:-exports", "-Xlint:-processing", "-Xlint:-removal", "-Xlint:-requires-automatic", + "-parameters")) if (javaVersion.canCompileOrRun(21)) { options.compilerArgs.add("-proc:full") }