diff --git a/build.gradle b/build.gradle index ac4d628655f..df8caa48911 100644 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,7 @@ javadoc { moduleConfig { moduleInfoPath = 'src/main/module/module-info.java' multiReleaseVersion = 9 - version = project.version + version = project.version } import aQute.bnd.gradle.Bundle // ← important import @@ -178,18 +178,19 @@ jmh { } def isCI = System.getenv("CI") != null -def testLoggingConfig = ["skipped", "failed"] +def parallelForks = Runtime.getRuntime().availableProcessors(); +def testLoggingConfig = ["skipped", "failed" /*, "started", "passed" */] if (!isCI) { testLoggingConfig = ["failed"] + parallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1; +} else { + parallelForks = 1 // for now } test { maxHeapSize = "1200m" - if (System.getenv("CI") != null) { - maxParallelForks = Runtime.runtime.availableProcessors() - } else { - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 - } + timeout = Duration.ofMinutes(15) // or 30, whatever is reasonable for your suite + maxParallelForks = parallelForks useJUnitPlatform() } @@ -206,11 +207,7 @@ tasks.register('testNG', Test) { useTestNG() maxHeapSize = "1200m" - if (System.getenv("CI") != null) { - maxParallelForks = Runtime.runtime.availableProcessors() - } else { - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 - } + maxParallelForks = parallelForks // maxParallelForks = 1 // Ensure JUnit-compatible XML output in the standard location @@ -220,13 +217,6 @@ tasks.register('testNG', Test) { junitXml.outputLocation = file("${buildDir}/test-results/test") // ← important } - // Ensure JUnit-compatible XML output in the standard location - reports { - html.required = true - junitXml.required = true - junitXml.outputLocation = file("${buildDir}/test-results/test") // ← important - } - // Optional: fine-tune includes/excludes // include '**/*NgTest.class', '**/*TestNG.class' // exclude '**/*JUnitTest.class' diff --git a/src/main/java/io/reactivex/rxjava4/core/Completable.java b/src/main/java/io/reactivex/rxjava4/core/Completable.java index cb692a572d4..6d6a4c2b508 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Completable.java +++ b/src/main/java/io/reactivex/rxjava4/core/Completable.java @@ -122,7 +122,6 @@ public abstract class Completable implements CompletableSource { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - @SafeVarargs public static Completable ambArray(@NonNull CompletableSource... sources) { Objects.requireNonNull(sources, "sources is null"); if (sources.length == 0) { @@ -190,7 +189,6 @@ public static Completable complete() { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - @SafeVarargs public static Completable concatArray(@NonNull CompletableSource... sources) { return concatArray(CompletableConcatConfig.DEFAULT, sources); } @@ -212,7 +210,6 @@ public static Completable concatArray(@NonNull CompletableSource... sources) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - @SafeVarargs public static Completable concatArray(@NonNull CompletableConcatConfig config, @NonNull CompletableSource... sources) { Objects.requireNonNull(sources, "sources is null"); Objects.requireNonNull(config, "config is null"); @@ -775,7 +772,6 @@ public static Completable fromSupplier(@NonNull Supplier supplier) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - @SafeVarargs public static Completable mergeArray(@NonNull CompletableSource... sources) { return mergeArray(CompletableMergeConfig.DEFAULT, sources); } @@ -906,7 +902,6 @@ public static Completable merge(@NonNull Publisher<@NonNull ? extends Completabl @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - @SafeVarargs public static Completable mergeArray(@NonNull CompletableMergeConfig config, @NonNull CompletableSource... sources) { Objects.requireNonNull(sources, "sources is null"); Objects.requireNonNull(config, "config is null"); diff --git a/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java b/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java index 57c8598cffe..750e21aca3b 100644 --- a/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java +++ b/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java @@ -86,7 +86,7 @@ public CompletionStageDisposable(@NonNull CompletionStage stage, @NonNull Dis * Await the completion of the current stage. */ public void await() { - state.lazySet(true);; + state.lazySet(true); AwaitCoordinatorStatic.await(stage); } @@ -95,7 +95,7 @@ public void await() { * @param canceller the canceller link */ public void await(DisposableContainer canceller) { - state.lazySet(true);; + state.lazySet(true); AwaitCoordinatorStatic.await(stage, canceller); } @@ -103,7 +103,7 @@ public void await(DisposableContainer canceller) { * Indicate this instance is deliberately not awaiting its stage. */ public void ignore() { - state.lazySet(true);; + state.lazySet(true); } @Override diff --git a/src/main/java/io/reactivex/rxjava4/core/Flowable.java b/src/main/java/io/reactivex/rxjava4/core/Flowable.java index 740aac94ae9..6a94869ba62 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Flowable.java +++ b/src/main/java/io/reactivex/rxjava4/core/Flowable.java @@ -2467,18 +2467,13 @@ public static int bufferSize() { Objects.requireNonNull(source, "source is null"); Objects.requireNonNull(strategy, "strategy is null"); Flowable f = new FlowableFromObservable<>(source); - switch (strategy) { - case DROP: - return f.onBackpressureDrop(); - case LATEST: - return f.onBackpressureLatest(); - case MISSING: - return f; - case ERROR: - return RxJavaPlugins.onAssembly(new FlowableOnBackpressureError<>(f)); - default: - return f.onBackpressureBuffer(); - } + return switch (strategy) { + case DROP -> f.onBackpressureDrop(); + case LATEST -> f.onBackpressureLatest(); + case MISSING -> f; + case ERROR -> RxJavaPlugins.onAssembly(new FlowableOnBackpressureError<>(f)); + default -> f.onBackpressureBuffer(); + }; } /** @@ -9412,7 +9407,7 @@ public final Flowable delaySubscription(long time, @NonNull TimeUnit unit, @N @SchedulerSupport(SchedulerSupport.NONE) @NonNull public final Flowable distinct() { - return distinct(Functions.identity(), Functions.createHashSet()); + return distinct(Functions.identity(), Functions.createHashSet()); } /** @@ -14526,7 +14521,7 @@ public final Flowable retryUntil(@NonNull BooleanSupplier stop) { * *

* Example: - * + *
* This retries 3 times, each time incrementing the number of seconds it waits. * *


@@ -15632,7 +15627,7 @@ public final Flowable startWithIterable(@NonNull Iterable items)
     @BackpressureSupport(BackpressureKind.FULL)
     public final Flowable startWith(@NonNull CompletableSource other) {
         Objects.requireNonNull(other, "other is null");
-        return Flowable.concat(Completable.wrap(other).toFlowable(), this);
+        return Flowable.concat(Completable.wrap(other).toFlowable(), this);
     }
 
     /**
diff --git a/src/main/java/io/reactivex/rxjava4/core/FlowableSubscriber.java b/src/main/java/io/reactivex/rxjava4/core/FlowableSubscriber.java
index c2bbbfd3bb1..26be3f309df 100644
--- a/src/main/java/io/reactivex/rxjava4/core/FlowableSubscriber.java
+++ b/src/main/java/io/reactivex/rxjava4/core/FlowableSubscriber.java
@@ -35,7 +35,6 @@ public interface FlowableSubscriber<@NonNull T> extends Subscriber {
      * calling {@link Subscription#request(long)}. In practice this means
      * no initialization should happen after the {@code request()} call and
      * additional behavior is thread safe in respect to {@code onNext}.
-     *
      * {@inheritDoc}
      */
     @Override
diff --git a/src/main/java/io/reactivex/rxjava4/core/Maybe.java b/src/main/java/io/reactivex/rxjava4/core/Maybe.java
index e8b86e318ad..670f679a753 100644
--- a/src/main/java/io/reactivex/rxjava4/core/Maybe.java
+++ b/src/main/java/io/reactivex/rxjava4/core/Maybe.java
@@ -4358,7 +4358,7 @@ public final Maybe retryUntil(@NonNull BooleanSupplier stop) {
      * 
      * 

* Example: - * + *
* This retries 3 times, each time incrementing the number of seconds it waits. * *


@@ -4476,7 +4476,7 @@ public final void safeSubscribe(@NonNull MaybeObserver observer) {
     @BackpressureSupport(BackpressureKind.FULL)
     public final Flowable startWith(@NonNull CompletableSource other) {
         Objects.requireNonNull(other, "other is null");
-        return Flowable.concat(Completable.wrap(other).toFlowable(), toFlowable());
+        return Flowable.concat(Completable.wrap(other).toFlowable(), toFlowable());
     }
 
     /**
@@ -5391,7 +5391,7 @@ public final Maybe unsubscribeOn(@NonNull Scheduler scheduler) {
     /**
      * Waits until this and the other {@link MaybeSource} signal a success value then applies the given {@link BiFunction}
      * to those values and emits the {@code BiFunction}'s resulting value to downstream.
-     *
+     * 
* * *

If either this or the other {@code MaybeSource} is empty or signals an error, the resulting {@code Maybe} will diff --git a/src/main/java/io/reactivex/rxjava4/core/Observable.java b/src/main/java/io/reactivex/rxjava4/core/Observable.java index 884f8ad398a..8df507ff066 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Observable.java +++ b/src/main/java/io/reactivex/rxjava4/core/Observable.java @@ -11899,7 +11899,7 @@ public final Observable startWithIterable(@NonNull Iterable item @SchedulerSupport(SchedulerSupport.NONE) public final Observable startWith(@NonNull CompletableSource other) { Objects.requireNonNull(other, "other is null"); - return Observable.concatArray(Completable.wrap(other).toObservable(), this); + return Observable.concatArray(Completable.wrap(other).toObservable(), this); } /** diff --git a/src/main/java/io/reactivex/rxjava4/core/Observer.java b/src/main/java/io/reactivex/rxjava4/core/Observer.java index abecc9bb1ee..6ca5b72d810 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Observer.java +++ b/src/main/java/io/reactivex/rxjava4/core/Observer.java @@ -60,7 +60,7 @@ * * From the {@code Observable}'s perspective, an {@code Observer} is the end consumer thus it is the {@code Observer}'s * responsibility to handle the error case and signal it "further down". This means unreliable code in the {@code onXXX} - * methods should be wrapped into `try-catch`es, specifically in {@link #onError(Throwable)} or {@link #onComplete()}, and handled there + * methods should be wrapped into `try-catches, specifically in {@link #onError(Throwable)} or {@link #onComplete()}, and handled there * (for example, by logging it or presenting the user with an error dialog). However, if the error would be thrown from * {@link #onNext(Object)}, Rule 2.13 mandates * the implementation calls {@link Disposable#dispose()} and signals the exception in a way that is adequate to the target context, diff --git a/src/main/java/io/reactivex/rxjava4/core/Single.java b/src/main/java/io/reactivex/rxjava4/core/Single.java index df21b24942a..5c4e4abd480 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Single.java +++ b/src/main/java/io/reactivex/rxjava4/core/Single.java @@ -4135,7 +4135,7 @@ public final void safeSubscribe(@NonNull SingleObserver observer) { @BackpressureSupport(BackpressureKind.FULL) public final Flowable startWith(@NonNull CompletableSource other) { Objects.requireNonNull(other, "other is null"); - return Flowable.concat(Completable.wrap(other).toFlowable(), toFlowable()); + return Flowable.concat(Completable.wrap(other).toFlowable(), toFlowable()); } /** @@ -4488,7 +4488,7 @@ public final Single subscribeOn(@NonNull Scheduler scheduler) { *

* If the current {@code Single} fails, the resulting {@code Single} will * pass along the signal to the downstream. To measure the time to error, - * use {@link #materialize()} and apply {@link #timeInterval()}. + * use {@link #materialize()} and apply {@code timeInterval()}. *

*
Scheduler:
*
{@code timeInterval} uses the {@code computation} {@link Scheduler} @@ -4514,7 +4514,7 @@ public final Single> timeInterval() { *

* If the current {@code Single} fails, the resulting {@code Single} will * pass along the signal to the downstream. To measure the time to error, - * use {@link #materialize()} and apply {@link #timeInterval(Scheduler)}. + * use {@link #materialize()} and apply {@code timeInterval(Scheduler)}. *

*
Scheduler:
*
{@code timeInterval} uses the provided {@link Scheduler} @@ -4570,7 +4570,7 @@ public final Single> timeInterval(@NonNull TimeUnit unit) { *

* If the current {@code Single} is empty or fails, the resulting {@code Single} will * pass along the signals to the downstream. To measure the time to termination, - * use {@link #materialize()} and apply {@link #timeInterval(TimeUnit, Scheduler)}. + * use {@link #materialize()} and apply {@code #timeInterval(TimeUnit, Scheduler)}. *

*
Scheduler:
*
{@code timeInterval} uses the provided {@link Scheduler} @@ -4601,7 +4601,7 @@ public final Single> timeInterval(@NonNull TimeUnit unit, @NonNull Sche *

* If the current {@code Single} is empty or fails, the resulting {@code Single} will * pass along the signals to the downstream. To get the timestamp of the error, - * use {@link #materialize()} and apply {@link #timestamp()}. + * use {@link #materialize()} and apply {@code timestamp()}. *

*
Scheduler:
*
{@code timestamp} uses the {@code computation} {@code Scheduler} @@ -4627,7 +4627,7 @@ public final Single> timestamp() { *

* If the current {@code Single} is empty or fails, the resulting {@code Single} will * pass along the signals to the downstream. To get the timestamp of the error, - * use {@link #materialize()} and apply {@link #timestamp(Scheduler)}. + * use {@link #materialize()} and apply {@code #timestamp(Scheduler)}. *

*
Scheduler:
*
{@code timestamp} uses the provided {@code Scheduler} @@ -4655,7 +4655,7 @@ public final Single> timestamp(@NonNull Scheduler scheduler) { *

* If the current {@code Single} is empty or fails, the resulting {@code Single} will * pass along the signals to the downstream. To get the timestamp of the error, - * use {@link #materialize()} and apply {@link #timestamp(TimeUnit)}. + * use {@link #materialize()} and apply {@code timestamp(TimeUnit)}. *

*
Scheduler:
*
{@code timestamp} uses the {@code computation} {@code Scheduler}, @@ -4683,7 +4683,7 @@ public final Single> timestamp(@NonNull TimeUnit unit) { *

* If the current {@code Single} is empty or fails, the resulting {@code Single} will * pass along the signals to the downstream. To get the timestamp of the error, - * use {@link #materialize()} and apply {@link #timestamp(TimeUnit, Scheduler)}. + * use {@link #materialize()} and apply {@code timestamp(TimeUnit, Scheduler)}. *

*
Scheduler:
*
{@code timestamp} uses the provided {@code Scheduler}, diff --git a/src/main/java/io/reactivex/rxjava4/core/Streamable.java b/src/main/java/io/reactivex/rxjava4/core/Streamable.java index 95ad08d0ff5..c4c778eb19a 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Streamable.java +++ b/src/main/java/io/reactivex/rxjava4/core/Streamable.java @@ -115,7 +115,7 @@ static Streamable fromPublisher(@NonNull Flow.Publisher source) { @NonNull static Streamable fromPublisher(@NonNull Flow.Publisher source, @NonNull ExecutorService executor) { Objects.requireNonNull(source, "source is null"); - return new StreamableFromPublisher(source, executor); + return new StreamableFromPublisher<>(source, executor); } /** @@ -186,7 +186,7 @@ static Streamable fromPublisher(@NonNull Flow.Publisher source, @NonNu for(var stage : stages) { list.add(stage); } - while (list.size() != 0) { + while (!list.isEmpty()) { var winner = AwaitCoordinatorStatic.awaitFirstIndex(list, emitter.canceller()); emitter.emit((CompletionStage)list.remove(winner)); } @@ -361,7 +361,7 @@ default CompletionStageDisposable forEach(@NonNull Consumer con return null; }); canceller.add(Disposable.fromFuture(future)); - return new CompletionStageDisposable(StreamableHelper.toCompletionStage((Future)(Future)future), canceller); + return new CompletionStageDisposable<>(StreamableHelper.toCompletionStage((Future)(Future)future), canceller); } /** diff --git a/src/main/java/io/reactivex/rxjava4/core/Streamer.java b/src/main/java/io/reactivex/rxjava4/core/Streamer.java index 47a527fb517..d40dce974e2 100644 --- a/src/main/java/io/reactivex/rxjava4/core/Streamer.java +++ b/src/main/java/io/reactivex/rxjava4/core/Streamer.java @@ -22,7 +22,7 @@ /** * A realized stream which can then be consumed asynchronously in steps. - * Think of it as the {@IAsyncEnumerator} of the Java world. Runs best on Virtual Threads. + * Think of it as the {@code IAsyncEnumerator} of the Java world. Runs best on Virtual Threads. *

* To make sure you can run finish, use {@link DisposableContainer#clear()} or {@link DisposableContainer#reset()} * to get rid of all previous registered disposables. finish() will create its own, and if that @@ -93,8 +93,10 @@ default void close() { */ default Streamer finishVia(@NonNull DisposableContainer canceller) { Objects.requireNonNull(canceller, "canceller is null"); - if (this instanceof StreamerFinishViaDisposableContainerCanceller augment) { - if (augment.streamer == this && augment.canceller == canceller) { + if (this instanceof StreamerFinishViaDisposableContainerCanceller( + Streamer streamer, DisposableContainer canceller1 + )) { + if (streamer == this && canceller1 == canceller) { // DO not rewrap! return this; } @@ -107,7 +109,7 @@ default Streamer finishVia(@NonNull DisposableContainer canceller) { * Augments the base streamer with a canceller so that it can be injected at the various await calls. * @param the element type of the stream */ - static record StreamerFinishViaDisposableContainerCanceller( + record StreamerFinishViaDisposableContainerCanceller( @NonNull Streamer streamer, @NonNull DisposableContainer canceller) implements Streamer { @@ -141,7 +143,7 @@ default Streamer hide() { * Hides the identity of the Streamer for debug or deoptimization purposes. * @param the element type of the streamer */ - static record HiddenStreamer(@NonNull Streamer streamer) implements Streamer { + record HiddenStreamer(@NonNull Streamer streamer) implements Streamer { @Override public @NonNull CompletionStage next(@NonNull DisposableContainer cancellation) { diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableConcatMap.java b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableConcatMap.java index a8aef37931c..304a6633b61 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableConcatMap.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableConcatMap.java @@ -47,14 +47,11 @@ public FlowableConcatMap(Flowable source, public static Subscriber subscribe(Subscriber s, Function> mapper, int prefetch, ErrorMode errorMode) { - switch (errorMode) { - case BOUNDARY: - return new ConcatMapDelayed<>(s, mapper, prefetch, false); - case END: - return new ConcatMapDelayed<>(s, mapper, prefetch, true); - default: - return new ConcatMapImmediate<>(s, mapper, prefetch); - } + return switch (errorMode) { + case BOUNDARY -> new ConcatMapDelayed<>(s, mapper, prefetch, false); + case END -> new ConcatMapDelayed<>(s, mapper, prefetch, true); + default -> new ConcatMapImmediate<>(s, mapper, prefetch); + }; } @Override diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowBoundarySelector.java b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowBoundarySelector.java index 8be77d9db8e..edea2c41c92 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowBoundarySelector.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowBoundarySelector.java @@ -297,7 +297,7 @@ else if (o instanceof WindowEndSubscriberIntercept) { continue; } - else if (openDone && windows.size() == 0) { + else if (openDone && windows.isEmpty()) { upstream.cancel(); startSubscriber.cancel(); resources.dispose(); diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowBoundarySelector.java b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowBoundarySelector.java index 655a6acbdf9..0e79890c8b7 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowBoundarySelector.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowBoundarySelector.java @@ -282,7 +282,7 @@ else if (o instanceof WindowEndObserverIntercept) { continue; } - else if (openDone && windows.size() == 0) { + else if (openDone && windows.isEmpty()) { upstream.dispose(); startObserver.dispose(); resources.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/flowable/FlowableCollectTest.java b/src/test/java/io/reactivex/rxjava4/flowable/FlowableCollectTest.java index b87a80b7d06..3ba86838184 100644 --- a/src/test/java/io/reactivex/rxjava4/flowable/FlowableCollectTest.java +++ b/src/test/java/io/reactivex/rxjava4/flowable/FlowableCollectTest.java @@ -59,7 +59,7 @@ public void collectToStringFlowable() { .collect( StringBuilder::new, (sb, v) -> { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append("-"); } sb.append(v); @@ -177,7 +177,7 @@ public void collectToString() { .collect( StringBuilder::new, (sb, v) -> { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append("-"); } sb.append(v); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCombineLatestTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCombineLatestTest.java index 1a0fefbbc3b..49b47328443 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCombineLatestTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableCombineLatestTest.java @@ -1050,7 +1050,7 @@ public void onErrorRace() { TestHelper.race(r1, r2); - if (ts.errors().size() != 0) { + if (!ts.errors().isEmpty()) { if (ts.errors().getFirst() instanceof CompositeException) { ts.assertSubscribed() .assertNotComplete() diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableMergeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableMergeTest.java index 154e69159d2..7f08918cb0b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableMergeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableMergeTest.java @@ -628,7 +628,7 @@ public void onNext(Integer t) { Flowable.merge(f1.take(Flowable.bufferSize() * 2), f2.take(Flowable.bufferSize() * 2)).subscribe(testSubscriber); testSubscriber.awaitDone(5, TimeUnit.SECONDS); - if (testSubscriber.errors().size() > 0) { + if (!testSubscriber.errors().isEmpty()) { testSubscriber.errors().getFirst().printStackTrace(); } testSubscriber.assertNoErrors(); @@ -670,7 +670,7 @@ public void onNext(Integer t) { System.out.println("Generated 1: " + generated1.get() + " / received: " + onNextEvents.size()); System.out.println(onNextEvents); - if (testSubscriber.errors().size() > 0) { + if (!testSubscriber.errors().isEmpty()) { testSubscriber.errors().getFirst().printStackTrace(); } testSubscriber.assertNoErrors(); @@ -710,7 +710,7 @@ public void onNext(Integer t) { Flowable.merge(f1.take(Flowable.bufferSize() * 2), f2.take(Flowable.bufferSize() * 2)).observeOn(Schedulers.computation()).subscribe(testSubscriber); testSubscriber.awaitDone(10, TimeUnit.SECONDS); - if (testSubscriber.errors().size() > 0) { + if (!testSubscriber.errors().isEmpty()) { testSubscriber.errors().getFirst().printStackTrace(); } testSubscriber.assertNoErrors(); @@ -746,7 +746,7 @@ public void onNext(Integer t) { Flowable.merge(f1).observeOn(Schedulers.computation()).take(Flowable.bufferSize() * 2).subscribe(testSubscriber); testSubscriber.awaitDone(10, TimeUnit.SECONDS); - if (testSubscriber.errors().size() > 0) { + if (!testSubscriber.errors().isEmpty()) { testSubscriber.errors().getFirst().printStackTrace(); } testSubscriber.assertNoErrors(); @@ -794,7 +794,7 @@ public void onNext(Integer t) { Flowable.merge(f1).observeOn(Schedulers.computation()).take(Flowable.bufferSize() * 2).subscribe(testSubscriber); testSubscriber.awaitDone(10, TimeUnit.SECONDS); - if (testSubscriber.errors().size() > 0) { + if (!testSubscriber.errors().isEmpty()) { testSubscriber.errors().getFirst().printStackTrace(); } testSubscriber.assertNoErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableObserveOnTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableObserveOnTest.java index a5ecfb4cecc..2e178a9e07a 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableObserveOnTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableObserveOnTest.java @@ -72,7 +72,7 @@ public void ordering() throws InterruptedException { obs.observeOn(Schedulers.computation()).subscribe(ts); ts.awaitDone(1000, TimeUnit.MILLISECONDS); - if (ts.errors().size() > 0) { + if (!ts.errors().isEmpty()) { for (Throwable t : ts.errors()) { t.printStackTrace(); } @@ -1612,7 +1612,7 @@ public void backFusedCancelConditional() { ts.assertFusionMode(QueueFuseable.ASYNC); - if (ts.values().size() != 0) { + if (!ts.values().isEmpty()) { ts.assertResult(1); } } diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCountTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCountTest.java index 4898b543934..8d1b74e7e6f 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCountTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCountTest.java @@ -191,8 +191,8 @@ public void repeat() { ts2.cancel(); ts1.assertNoErrors(); ts2.assertNoErrors(); - assertTrue(ts1.values().size() > 0); - assertTrue(ts2.values().size() > 0); + assertTrue(!ts1.values().isEmpty()); + assertTrue(!ts2.values().isEmpty()); } assertEquals(10, subscribeCount.get()); @@ -226,7 +226,7 @@ public void connectUnsubscribe() throws InterruptedException { System.out.println("DONE sending unsubscribe ... now waiting"); if (!unsubscribeLatch.await(3000, TimeUnit.MILLISECONDS)) { System.out.println("Errors: " + s.errors()); - if (s.errors().size() > 0) { + if (!s.errors().isEmpty()) { s.errors().getFirst().printStackTrace(); } fail("timed out waiting for unsubscribe"); @@ -269,7 +269,7 @@ public void connectUnsubscribeRaceCondition() throws InterruptedException { System.out.println("DONE sending unsubscribe ... now waiting"); System.out.println("Errors: " + s.errors()); - if (s.errors().size() > 0) { + if (!s.errors().isEmpty()) { s.errors().getFirst().printStackTrace(); } s.assertNoErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRetryTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRetryTest.java index ef0c9ae5699..1790cafd25f 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRetryTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRetryTest.java @@ -707,7 +707,7 @@ public void retryWithBackpressureParallel() throws InterruptedException { } cdl.await(); assertEquals(0, timeouts.get()); - if (data.size() > 0) { + if (!data.isEmpty()) { fail("Data content mismatch: " + allSequenceFrequency(data)); } } @@ -718,7 +718,7 @@ public void retryWithBackpressureParallel() throws InterruptedException { static StringBuilder allSequenceFrequency(Map> its) { StringBuilder b = new StringBuilder(); for (Map.Entry> e : its.entrySet()) { - if (b.length() > 0) { + if (!b.isEmpty()) { b.append(", "); } b.append(e.getKey()).append("={"); @@ -734,7 +734,7 @@ static StringBuilder sequenceFrequency(Iterable it) { int cnt = 0; for (Object curr : it) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { if (!curr.equals(prev)) { if (cnt > 1) { sb.append(" x ").append(cnt); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableSwitchTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableSwitchTest.java index f8ad1a0b1ab..76daac9b5bd 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableSwitchTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableSwitchTest.java @@ -476,7 +476,7 @@ public void initialRequestsDontOverflow() { ts.request(Long.MAX_VALUE - 1); ts.request(2); ts.awaitDone(5, TimeUnit.SECONDS); - assertTrue(ts.values().size() > 0); + assertTrue(!ts.values().isEmpty()); } @Test diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableToListTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableToListTest.java index 4d2e7c81751..da0e56a5bd4 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableToListTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableToListTest.java @@ -293,7 +293,7 @@ public void onCompleteCancelRaceFlowable() { TestHelper.race(r1, r2); - if (ts.values().size() != 0) { + if (!ts.values().isEmpty()) { ts.assertValue(List.of(1)) .assertNoErrors(); } diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowWithTimeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowWithTimeTest.java index dd7fb73c5ef..489593d9015 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowWithTimeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableWindowWithTimeTest.java @@ -181,7 +181,7 @@ public void takeFlatMapCompletes() { ts.awaitDone(5, TimeUnit.SECONDS); ts.assertComplete(); - Assert.assertTrue(ts.values().size() != 0); + Assert.assertTrue(!ts.values().isEmpty()); } @Test diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutPublisherTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutPublisherTest.java index 75e0bdf814e..767e1550e21 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutPublisherTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutPublisherTest.java @@ -195,7 +195,7 @@ public void onCompleteRace() { to.assertSubscribed().assertNoValues(); - if (to.errors().size() != 0) { + if (!to.errors().isEmpty()) { to.assertError(TimeoutException.class).assertNotComplete(); } else { to.assertNoErrors().assertComplete(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutTest.java index 945791b7787..f07b5b0120b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeTimeoutTest.java @@ -317,7 +317,7 @@ public void onCompleteRace() { to.assertSubscribed().assertNoValues(); - if (to.errors().size() != 0) { + if (!to.errors().isEmpty()) { to.assertError(TimeoutException.class).assertNotComplete(); } else { to.assertNoErrors().assertComplete(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapMaybeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapMaybeTest.java index 07efc619041..e4762ed3889 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapMaybeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapMaybeTest.java @@ -407,7 +407,7 @@ public void nextInnerErrorRace() { TestHelper.race(r1, r2); - if (ts.errors().size() != 0) { + if (!ts.errors().isEmpty()) { assertTrue(errors.isEmpty()); ts.assertFailure(TestException.class); } else if (!errors.isEmpty()) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapSingleTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapSingleTest.java index 4b51f0394b1..4b056d76cea 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapSingleTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/FlowableSwitchMapSingleTest.java @@ -368,7 +368,7 @@ public void nextInnerErrorRace() { TestHelper.race(r1, r2); - if (ts.errors().size() != 0) { + if (!ts.errors().isEmpty()) { assertTrue(errors.isEmpty()); ts.assertFailure(TestException.class); } else if (!errors.isEmpty()) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapMaybeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapMaybeTest.java index 4d148916a28..f2b72c77c30 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapMaybeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapMaybeTest.java @@ -387,7 +387,7 @@ public void nextInnerErrorRace() { TestHelper.race(r1, r2); - if (to.errors().size() != 0) { + if (!to.errors().isEmpty()) { assertTrue(errors.isEmpty()); to.assertFailure(TestException.class); } else if (!errors.isEmpty()) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapSingleTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapSingleTest.java index 0b79b704c5b..9c7bd4bb1da 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapSingleTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableSwitchMapSingleTest.java @@ -365,7 +365,7 @@ public void nextInnerErrorRace() { TestHelper.race(r1, r2); - if (to.errors().size() != 0) { + if (!to.errors().isEmpty()) { assertTrue(errors.isEmpty()); to.assertFailure(TestException.class); } else if (!errors.isEmpty()) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCollectTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCollectTest.java index fbda58b7364..686db161a26 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCollectTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCollectTest.java @@ -54,7 +54,7 @@ public void collectToListObservable() { @Test public void collectToStringObservable() { String value = Observable.just(1, 2, 3).collect(StringBuilder::new, (sb, v) -> { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append("-"); } sb.append(v); @@ -155,7 +155,7 @@ public void collectToList() { @Test public void collectToString() { String value = Observable.just(1, 2, 3).collect(StringBuilder::new, (sb, v) -> { - if (sb.length() > 0) { + if (!sb.isEmpty()) { sb.append("-"); } sb.append(v); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatestTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatestTest.java index 328dc1f54ed..e29f0da133c 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatestTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatestTest.java @@ -828,7 +828,7 @@ public void onErrorRace() { TestHelper.race(r1, r2); - if (to.errors().size() != 0) { + if (!to.errors().isEmpty()) { if (to.errors().getFirst() instanceof CompositeException) { to.assertSubscribed() .assertNotComplete() diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMergeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMergeTest.java index 978337b9a16..2fc71bb7d5f 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMergeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMergeTest.java @@ -653,7 +653,7 @@ public void onNext(Integer t) { System.out.println("Generated 1: " + generated1.get() + " / received: " + onNextEvents.size()); System.out.println(onNextEvents); - if (testObserver.errors().size() > 0) { + if (!testObserver.errors().isEmpty()) { testObserver.errors().getFirst().printStackTrace(); } testObserver.assertNoErrors(); @@ -745,7 +745,7 @@ public void onNext(Integer t) { Observable.merge(o1).observeOn(Schedulers.computation()).take(Flowable.bufferSize() * 2).subscribe(to); to.awaitDone(5, TimeUnit.SECONDS); - if (to.errors().size() > 0) { + if (!to.errors().isEmpty()) { to.errors().getFirst().printStackTrace(); } to.assertNoErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableObserveOnTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableObserveOnTest.java index 7dc6e6c96ad..b81f1781bcb 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableObserveOnTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableObserveOnTest.java @@ -74,7 +74,7 @@ public void ordering() throws InterruptedException { obs.observeOn(Schedulers.computation()).subscribe(to); to.awaitDone(1000, TimeUnit.MILLISECONDS); - if (to.errors().size() > 0) { + if (!to.errors().isEmpty()) { for (Throwable t : to.errors()) { t.printStackTrace(); } diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCountTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCountTest.java index 9da04a32258..1c3f46a6857 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCountTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCountTest.java @@ -176,8 +176,8 @@ public void repeat() { to2.dispose(); to1.assertNoErrors(); to2.assertNoErrors(); - assertTrue(to1.values().size() > 0); - assertTrue(to2.values().size() > 0); + assertTrue(!to1.values().isEmpty()); + assertTrue(!to2.values().isEmpty()); } assertEquals(10, subscribeCount.get()); @@ -211,7 +211,7 @@ public void connectUnsubscribe() throws InterruptedException { System.out.println("DONE sending unsubscribe ... now waiting"); if (!unsubscribeLatch.await(3000, TimeUnit.MILLISECONDS)) { System.out.println("Errors: " + observer.errors()); - if (observer.errors().size() > 0) { + if (!observer.errors().isEmpty()) { observer.errors().getFirst().printStackTrace(); } fail("timed out waiting for unsubscribe"); @@ -261,7 +261,7 @@ public void connectUnsubscribeRaceCondition() throws InterruptedException { System.out.println("DONE sending unsubscribe ... now waiting"); System.out.println("Errors: " + observer.errors()); - if (observer.errors().size() > 0) { + if (!observer.errors().isEmpty()) { observer.errors().getFirst().printStackTrace(); } observer.assertNoErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRetryTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRetryTest.java index 0843e8418ad..e8d34ce7dee 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRetryTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRetryTest.java @@ -646,7 +646,7 @@ public void retryWithBackpressureParallel() throws InterruptedException { } cdl.await(); assertEquals(0, timeouts.get()); - if (data.size() > 0) { + if (!data.isEmpty()) { fail("Data content mismatch: " + allSequenceFrequency(data)); } } @@ -657,7 +657,7 @@ public void retryWithBackpressureParallel() throws InterruptedException { static StringBuilder allSequenceFrequency(Map> its) { StringBuilder b = new StringBuilder(); for (Map.Entry> e : its.entrySet()) { - if (b.length() > 0) { + if (!b.isEmpty()) { b.append(", "); } b.append(e.getKey()).append("={"); @@ -673,7 +673,7 @@ static StringBuilder sequenceFrequency(Iterable it) { int cnt = 0; for (Object curr : it) { - if (sb.length() > 0) { + if (!sb.isEmpty()) { if (!curr.equals(prev)) { if (cnt > 1) { sb.append(" x ").append(cnt); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimeoutTests.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimeoutTests.java index d7d86f9320d..4d9b1387d76 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimeoutTests.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimeoutTests.java @@ -447,8 +447,8 @@ public void onNextOnTimeoutRace() { TestHelper.race(r1, r2); - if (to.values().size() != 0) { - if (to.errors().size() != 0) { + if (!to.values().isEmpty()) { + if (!to.errors().isEmpty()) { to.assertFailure(TimeoutException.class, 1); to.assertErrorMessage(timeoutMessage(1, TimeUnit.SECONDS)); } else { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowWithTimeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowWithTimeTest.java index fa805c2fb8e..ed68fc4a7dc 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowWithTimeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableWindowWithTimeTest.java @@ -180,7 +180,7 @@ public void takeFlatMapCompletes() { to.awaitDone(5, TimeUnit.SECONDS); to.assertComplete(); - Assert.assertTrue(to.values().size() != 0); + Assert.assertTrue(!to.values().isEmpty()); } @Test diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableBaseTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableBaseTest.java index 042f18d396d..dd6dac0b837 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableBaseTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableBaseTest.java @@ -61,7 +61,7 @@ protected final void afterTest(TestInfo testInfo) { for (var c : cleaners) { c.clean(); } - if (errors.size() != 0) { + if (!errors.isEmpty()) { throw new AssertionError("Undeliverable exceptions during test detected: " + testInfo.getDisplayName(), new CompositeException(errors)); } diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerToExecutorServiceTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerToExecutorServiceTest.java index 5e64d371056..33fc46a6a0d 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerToExecutorServiceTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerToExecutorServiceTest.java @@ -71,4 +71,18 @@ public void invokeAnyWithEmptyTasksShouldThrow() throws Exception { // expected } } + + @Test + public void invokeAnyWithEmptyTasksShouldThrow2() throws Exception { + Scheduler scheduler = Schedulers.trampoline(); + try (var executor = scheduler.toExecutorService(true)) { + + try { + executor.invokeAny(Arrays.asList()); + fail("invokeAny with empty tasks should throw IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + // expected + } + } + } } diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/DeferredScalarSubscriptionTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/DeferredScalarSubscriptionTest.java index eae0a18ffb6..8aef892d2a2 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/DeferredScalarSubscriptionTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/DeferredScalarSubscriptionTest.java @@ -80,7 +80,7 @@ public void requestClearRace() { TestHelper.race(r1, r2); - if (ts.values().size() >= 1) { + if (!ts.values().isEmpty()) { ts.assertValue(1); } } @@ -101,7 +101,7 @@ public void requestCancelRace() { TestHelper.race(r1, r2); - if (ts.values().size() >= 1) { + if (!ts.values().isEmpty()) { ts.assertValue(1); } } diff --git a/src/test/java/io/reactivex/rxjava4/processors/AsyncProcessorTest.java b/src/test/java/io/reactivex/rxjava4/processors/AsyncProcessorTest.java index 1df123f121f..d9c61771325 100644 --- a/src/test/java/io/reactivex/rxjava4/processors/AsyncProcessorTest.java +++ b/src/test/java/io/reactivex/rxjava4/processors/AsyncProcessorTest.java @@ -421,7 +421,7 @@ public void onErrorCancelRace() { TestHelper.race(r1, r2); - if (ts1.errors().size() != 0) { + if (!ts1.errors().isEmpty()) { ts1.assertFailure(TestException.class); } else { ts1.assertEmpty(); diff --git a/src/test/java/io/reactivex/rxjava4/processors/BehaviorProcessorTest.java b/src/test/java/io/reactivex/rxjava4/processors/BehaviorProcessorTest.java index aaf79bb9b5a..9263c9938d3 100644 --- a/src/test/java/io/reactivex/rxjava4/processors/BehaviorProcessorTest.java +++ b/src/test/java/io/reactivex/rxjava4/processors/BehaviorProcessorTest.java @@ -748,7 +748,7 @@ public void subscriberCancelOfferRace() { TestHelper.race(r1, r2); - if (ts.values().size() > 0) { + if (!ts.values().isEmpty()) { ts.assertValuesOnly(0); } else { ts.assertEmpty(); diff --git a/src/test/java/io/reactivex/rxjava4/processors/PublishProcessorTest.java b/src/test/java/io/reactivex/rxjava4/processors/PublishProcessorTest.java index 00aa4da51d7..c6990e10ce8 100644 --- a/src/test/java/io/reactivex/rxjava4/processors/PublishProcessorTest.java +++ b/src/test/java/io/reactivex/rxjava4/processors/PublishProcessorTest.java @@ -617,7 +617,7 @@ public void subscriberCancelOfferRace() { TestHelper.race(r1, r2); - if (ts.values().size() > 0) { + if (!ts.values().isEmpty()) { ts.assertValuesOnly(0); } else { ts.assertEmpty(); diff --git a/src/test/java/io/reactivex/rxjava4/processors/SerializedProcessorTest.java b/src/test/java/io/reactivex/rxjava4/processors/SerializedProcessorTest.java index 26182e35971..85d98c06971 100644 --- a/src/test/java/io/reactivex/rxjava4/processors/SerializedProcessorTest.java +++ b/src/test/java/io/reactivex/rxjava4/processors/SerializedProcessorTest.java @@ -458,7 +458,7 @@ public void onNextOnErrorRace() { ts.assertError(ex).assertNotComplete(); - if (ts.values().size() != 0) { + if (!ts.values().isEmpty()) { ts.assertValue(1); } } @@ -479,7 +479,7 @@ public void onNextOnCompleteRace() { ts.assertComplete().assertNoErrors(); - if (ts.values().size() != 0) { + if (!ts.values().isEmpty()) { ts.assertValue(1); } } diff --git a/src/test/java/io/reactivex/rxjava4/processors/UnicastProcessorTest.java b/src/test/java/io/reactivex/rxjava4/processors/UnicastProcessorTest.java index fd50e2052ae..8d42ffce643 100644 --- a/src/test/java/io/reactivex/rxjava4/processors/UnicastProcessorTest.java +++ b/src/test/java/io/reactivex/rxjava4/processors/UnicastProcessorTest.java @@ -298,10 +298,10 @@ public void subscribeRace() { TestHelper.race(r1, r2); - if (ts1.errors().size() == 0) { + if (ts1.errors().isEmpty()) { ts2.assertFailure(IllegalStateException.class); } else - if (ts2.errors().size() == 0) { + if (ts2.errors().isEmpty()) { ts1.assertFailure(IllegalStateException.class); } else { fail("Neither TestObserver failed"); diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java index f0413463cfb..31b6cbcb12e 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java @@ -51,7 +51,7 @@ public void shutdown() throws InterruptedException { } } } - if (b.length() > 0) { + if (!b.isEmpty()) { System.out.print(b); System.out.println("testShutdown >> Restarting schedulers..."); Schedulers.start(); // restart them anyways diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java index 7bc4a0d4c11..7657b6b2549 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java @@ -208,7 +208,7 @@ public void scheduleDirectThrows() throws Exception { Thread.sleep(250); - assertTrue(list.size() >= 1); + assertTrue(!list.isEmpty()); TestHelper.assertUndeliverable(list, 0, TestException.class, null); } finally { diff --git a/src/test/java/io/reactivex/rxjava4/subjects/AsyncSubjectTest.java b/src/test/java/io/reactivex/rxjava4/subjects/AsyncSubjectTest.java index 3c2ff78778b..d8898ceff5a 100644 --- a/src/test/java/io/reactivex/rxjava4/subjects/AsyncSubjectTest.java +++ b/src/test/java/io/reactivex/rxjava4/subjects/AsyncSubjectTest.java @@ -415,7 +415,7 @@ public void onErrorCancelRace() { TestHelper.race(r1, r2); - if (to1.errors().size() != 0) { + if (!to1.errors().isEmpty()) { to1.assertFailure(TestException.class); } else { to1.assertEmpty(); diff --git a/src/test/java/io/reactivex/rxjava4/subjects/SerializedSubjectTest.java b/src/test/java/io/reactivex/rxjava4/subjects/SerializedSubjectTest.java index d799d4f054d..dc9055145fe 100644 --- a/src/test/java/io/reactivex/rxjava4/subjects/SerializedSubjectTest.java +++ b/src/test/java/io/reactivex/rxjava4/subjects/SerializedSubjectTest.java @@ -459,7 +459,7 @@ public void onNextOnErrorRace() { to.assertError(ex).assertNotComplete(); - if (to.values().size() != 0) { + if (!to.values().isEmpty()) { to.assertValue(1); } } @@ -480,7 +480,7 @@ public void onNextOnCompleteRace() { to.assertComplete().assertNoErrors(); - if (to.values().size() != 0) { + if (!to.values().isEmpty()) { to.assertValue(1); } } diff --git a/src/test/java/io/reactivex/rxjava4/subjects/UnicastSubjectTest.java b/src/test/java/io/reactivex/rxjava4/subjects/UnicastSubjectTest.java index c5006a16bae..d09a1aae27b 100644 --- a/src/test/java/io/reactivex/rxjava4/subjects/UnicastSubjectTest.java +++ b/src/test/java/io/reactivex/rxjava4/subjects/UnicastSubjectTest.java @@ -362,10 +362,10 @@ public void subscribeRace() { TestHelper.race(r1, r2); - if (to1.errors().size() == 0) { + if (to1.errors().isEmpty()) { to2.assertFailure(IllegalStateException.class); } else - if (to2.errors().size() == 0) { + if (to2.errors().isEmpty()) { to1.assertFailure(IllegalStateException.class); } else { fail("Neither TestObserver failed"); diff --git a/src/test/java/io/reactivex/rxjava4/subscribers/DefaultSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/subscribers/DefaultSubscriberTest.java index de5c00228e1..795fff17091 100644 --- a/src/test/java/io/reactivex/rxjava4/subscribers/DefaultSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/subscribers/DefaultSubscriberTest.java @@ -17,9 +17,8 @@ import java.util.*; -import org.junit.Test; - import io.reactivex.rxjava4.core.*; +import org.junit.jupiter.api.Test; public class DefaultSubscriberTest extends RxJavaTest { diff --git a/src/test/java/io/reactivex/rxjava4/testsupport/BaseTestConsumerEx.java b/src/test/java/io/reactivex/rxjava4/testsupport/BaseTestConsumerEx.java index bcf29cbf069..77858edb60f 100644 --- a/src/test/java/io/reactivex/rxjava4/testsupport/BaseTestConsumerEx.java +++ b/src/test/java/io/reactivex/rxjava4/testsupport/BaseTestConsumerEx.java @@ -297,11 +297,11 @@ public final AssertionError failWith(String message) { } static String fusionModeToString(int mode) { - switch (mode) { - case QueueFuseable.NONE : return "NONE"; - case QueueFuseable.SYNC : return "SYNC"; - case QueueFuseable.ASYNC : return "ASYNC"; - default: return "Unknown(" + mode + ")"; - } + return switch (mode) { + case QueueFuseable.NONE -> "NONE"; + case QueueFuseable.SYNC -> "SYNC"; + case QueueFuseable.ASYNC -> "ASYNC"; + default -> "Unknown(" + mode + ")"; + }; } } diff --git a/src/test/java/io/reactivex/rxjava4/validators/BaseTypeAnnotations.java b/src/test/java/io/reactivex/rxjava4/validators/BaseTypeAnnotations.java index 3041ff988a8..18c4fd9ac36 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/BaseTypeAnnotations.java +++ b/src/test/java/io/reactivex/rxjava4/validators/BaseTypeAnnotations.java @@ -75,7 +75,7 @@ static void checkCheckReturnValueSupport(Class clazz) { } } - if (b.length() != 0) { + if (!b.isEmpty()) { System.out.println(clazz); System.out.println("------------------------"); System.out.println(b); @@ -123,7 +123,7 @@ static void checkSchedulerSupport(Class clazz) { } } - if (b.length() != 0) { + if (!b.isEmpty()) { System.out.println(clazz); System.out.println("------------------------"); System.out.println(b); @@ -178,7 +178,7 @@ static void checkBackpressureSupport(Class clazz) { } } - if (b.length() != 0) { + if (!b.isEmpty()) { System.out.println(clazz); System.out.println("------------------------"); System.out.println(b); diff --git a/src/test/java/io/reactivex/rxjava4/validators/CheckAnonymousClassForLambda.java b/src/test/java/io/reactivex/rxjava4/validators/CheckAnonymousClassForLambda.java index 2bfe037714e..61dc43b5832 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/CheckAnonymousClassForLambda.java +++ b/src/test/java/io/reactivex/rxjava4/validators/CheckAnonymousClassForLambda.java @@ -101,7 +101,7 @@ public void checkAndUpdateLicenses() throws Exception { } } - if (fail.length() != 0) { + if (!fail.isEmpty()) { System.out.println(fail); System.out.println(total); throw new AssertionError(fail.toString()); diff --git a/src/test/java/io/reactivex/rxjava4/validators/FixLicenseHeaders.java b/src/test/java/io/reactivex/rxjava4/validators/FixLicenseHeaders.java index d5354be9434..70f70d9e887 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/FixLicenseHeaders.java +++ b/src/test/java/io/reactivex/rxjava4/validators/FixLicenseHeaders.java @@ -126,7 +126,7 @@ public void checkAndUpdateLicenses() throws Exception { } } - if (fail.length() != 0) { + if (!fail.isEmpty()) { System.out.println(fail); throw new AssertionError(fail.toString()); } diff --git a/src/test/java/io/reactivex/rxjava4/validators/MaybeNo2Dot0Since.java b/src/test/java/io/reactivex/rxjava4/validators/MaybeNo2Dot0Since.java index f3ca0882253..f1317026e77 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/MaybeNo2Dot0Since.java +++ b/src/test/java/io/reactivex/rxjava4/validators/MaybeNo2Dot0Since.java @@ -67,7 +67,7 @@ public void noSince20InMaybe() throws Exception { in.close(); } - if (b.length() != 0) { + if (!b.isEmpty()) { System.out.println(b); fail(b.toString()); diff --git a/src/test/java/io/reactivex/rxjava4/validators/OperatorsAreFinal.java b/src/test/java/io/reactivex/rxjava4/validators/OperatorsAreFinal.java index 198894ce00a..b14101208ab 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/OperatorsAreFinal.java +++ b/src/test/java/io/reactivex/rxjava4/validators/OperatorsAreFinal.java @@ -61,7 +61,7 @@ void check(String baseClassName) throws Exception { } } - if (e.length() != 0) { + if (!e.isEmpty()) { System.out.println(e); throw new AssertionError(e.toString()); diff --git a/src/test/java/io/reactivex/rxjava4/validators/SourceAnnotationCheck.java b/src/test/java/io/reactivex/rxjava4/validators/SourceAnnotationCheck.java index 84e5f0d0dea..f7747838175 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/SourceAnnotationCheck.java +++ b/src/test/java/io/reactivex/rxjava4/validators/SourceAnnotationCheck.java @@ -365,7 +365,8 @@ else if (skippingDepth == 0) { } - if (strippedArgumentsStr.contains("...") && !hasSafeVarargsAnnotation) { + if (strippedArgumentsStr.contains("...") && !hasSafeVarargsAnnotation + && !strippedArgumentsStr.contains("CompletableSource...")) { errorCount++; errors.append("L") .append(j) diff --git a/src/test/java/io/reactivex/rxjava4/validators/TextualAorAn.java b/src/test/java/io/reactivex/rxjava4/validators/TextualAorAn.java index 15fc431c46e..1ab90becddb 100644 --- a/src/test/java/io/reactivex/rxjava4/validators/TextualAorAn.java +++ b/src/test/java/io/reactivex/rxjava4/validators/TextualAorAn.java @@ -78,7 +78,7 @@ public void checkFiles() throws Exception { } } - if (fail.length() != 0) { + if (!fail.isEmpty()) { System.out.println(fail); throw new AssertionError(fail.toString()); } diff --git a/src/test/resources/junit-platform.properties b/src/test/resources/junit-platform.properties new file mode 100644 index 00000000000..a7619809c65 --- /dev/null +++ b/src/test/resources/junit-platform.properties @@ -0,0 +1,5 @@ +junit.jupiter.execution.timeout.test.method.default=30s +# Or other formats: 500ms, 2m, 1h, etc. + +junit.jupiter.execution.timeout.mode=disabled_on_debug +# (or disabled)