From f54d023836f03aa37c8b177f0c8c87463d7544a4 Mon Sep 17 00:00:00 2001 From: Phil Werli Date: Sun, 4 Dec 2022 11:59:50 +0100 Subject: [PATCH] Include a rule to rewrite `Mono.just(null)` to `Mono.empty()` Should never happen in practice, but it's not a compile time error. --- .../tech/picnic/errorprone/refasterrules/ReactorRules.java | 2 +- .../errorprone/refasterrules/ReactorRulesTestInput.java | 4 ++-- .../errorprone/refasterrules/ReactorRulesTestOutput.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java index a614a88250..94d80a5c87 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/refasterrules/ReactorRules.java @@ -64,7 +64,7 @@ Mono after(Supplier supplier) { static final class MonoEmpty { @BeforeTemplate Mono before() { - return Mono.justOrEmpty(null); + return Refaster.anyOf(Mono.just(null), Mono.justOrEmpty(null)); } @AfterTemplate diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java index d646c21ed0..e187eb487f 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestInput.java @@ -34,8 +34,8 @@ ImmutableSet> testMonoFromSupplier() { Mono.fromCallable(this::toString)); } - Mono testMonoEmpty() { - return Mono.justOrEmpty(null); + ImmutableSet> testMonoEmpty() { + return ImmutableSet.of(Mono.just(null), Mono.justOrEmpty(null)); } ImmutableSet> testMonoJustOrEmpty() { diff --git a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java index 50f7903137..c143647f84 100644 --- a/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java +++ b/error-prone-contrib/src/test/resources/tech/picnic/errorprone/refasterrules/ReactorRulesTestOutput.java @@ -37,8 +37,8 @@ ImmutableSet> testMonoFromSupplier() { Mono.fromSupplier(this::toString)); } - Mono testMonoEmpty() { - return Mono.empty(); + ImmutableSet> testMonoEmpty() { + return ImmutableSet.of(Mono.empty(), Mono.empty()); } ImmutableSet> testMonoJustOrEmpty() {