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 66e391cebcf..c99c77482a5 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 @@ -4,7 +4,6 @@ import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; import static com.google.errorprone.refaster.ImportPolicy.STATIC_IMPORT_ALWAYS; import static java.util.function.Function.identity; -import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static reactor.function.TupleUtils.function; @@ -20,7 +19,6 @@ import java.time.Duration; import java.util.Comparator; import java.util.HashMap; -import java.util.List; import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.BiConsumer; @@ -29,7 +27,6 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; -import java.util.stream.Stream; import org.jspecify.annotations.Nullable; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -1306,33 +1303,4 @@ Duration after(StepVerifier.LastStep step, Duration duration) { return step.verifyTimeout(duration); } } - - /** Avoid accidental blocking with {@link Flux#toStream()}. */ - // XXX: The alternative may lose some performance due to - // buffering and prefetching - static final class FluxToStream { - @BeforeTemplate - Stream before(Flux flux) { - return flux.toStream(); - } - - @AfterTemplate - Stream after(Flux flux) { - return flux.collect(toList()).block().stream(); - } - } - - /** Avoid accidental blocking with {@link Flux#toIterable()}. */ - // XXX: The alternative may lose some performance due to buffering and prefetching - static final class FluxToIterable { - @BeforeTemplate - Iterable before(Flux flux) { - return flux.toIterable(); - } - - @AfterTemplate - List after(Flux flux) { - return flux.collect(toList()).block(); - } - } } 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 16c3f9f198e..25596c5cc3d 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 @@ -12,8 +12,6 @@ import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -25,7 +23,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { @Override public ImmutableSet elidedTypesAndStaticImports() { - return ImmutableSet.of(assertThat(0), Collectors.class, HashMap.class, ImmutableMap.class); + return ImmutableSet.of(assertThat(0), HashMap.class, ImmutableMap.class); } ImmutableSet> testMonoFromSupplier() { @@ -404,12 +402,4 @@ Duration testStepVerifierLastStepVerifyErrorMessage() { Duration testStepVerifierLastStepVerifyTimeout() { return StepVerifier.create(Mono.empty()).expectTimeout(Duration.ZERO).verify(); } - - Stream testFluxToStream() { - return Flux.just(1, 2, 3).toStream(); - } - - Iterable testFluxToIterable() { - return Flux.just(1, 2, 3).toIterable(); - } } 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 679a27e1d77..7c471e53145 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 @@ -14,8 +14,6 @@ import java.util.Optional; import java.util.concurrent.Callable; import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.function.TupleUtils; @@ -28,7 +26,7 @@ final class ReactorRulesTest implements RefasterRuleCollectionTestCase { @Override public ImmutableSet elidedTypesAndStaticImports() { - return ImmutableSet.of(assertThat(0), Collectors.class, HashMap.class, ImmutableMap.class); + return ImmutableSet.of(assertThat(0), HashMap.class, ImmutableMap.class); } ImmutableSet> testMonoFromSupplier() { @@ -393,12 +391,4 @@ Duration testStepVerifierLastStepVerifyErrorMessage() { Duration testStepVerifierLastStepVerifyTimeout() { return StepVerifier.create(Mono.empty()).verifyTimeout(Duration.ZERO); } - - Stream testFluxToStream() { - return Flux.just(1, 2, 3).collect(Collectors.toList()).block().stream(); - } - - Iterable testFluxToIterable() { - return Flux.just(1, 2, 3).collect(Collectors.toList()).block(); - } }