diff --git a/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java b/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java new file mode 100644 index 0000000000..94413fec39 --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/core/CompletionStageDisposable.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.core; + +import java.util.concurrent.CompletionStage; + +import io.reactivex.rxjava4.disposables.Disposable; + +public record CompletionStageDisposable(CompletionStage stage, Disposable disposable) { + +} diff --git a/src/main/java/io/reactivex/rxjava4/core/Streamable.java b/src/main/java/io/reactivex/rxjava4/core/Streamable.java new file mode 100644 index 0000000000..68b336cb88 --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/core/Streamable.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.core; + +import java.lang.reflect.InvocationTargetException; +import java.util.Objects; +import java.util.concurrent.*; + +import io.reactivex.rxjava4.annotations.NonNull; +import io.reactivex.rxjava4.disposables.*; +import io.reactivex.rxjava4.exceptions.Exceptions; +import io.reactivex.rxjava4.functions.Consumer; +import io.reactivex.rxjava4.internal.operators.streamable.*; + +/** + * The {@code IAsyncEnumerable} of the Java world. + * Runs best with Virtual Threads. + * TODO proper docs + * @param the element type of the stream. + * @since 4.0.0 + */ +public abstract class Streamable<@NonNull T> { + + /** + * Realizes the stream and returns an interface that let's one consume it. + * @param cancellation where to register and listen for cancellation calls. + * @return the Streamer instance to consume. + */ + @NonNull + public abstract Streamer stream(@NonNull DisposableContainer cancellation); + + /** + * Realizes the stream and returns an interface that let's one consume it. + * @return the Streamer instance to consume. + */ + @NonNull + public final Streamer stream() { + return stream(new CompositeDisposable()); // FIXME, use a practically no-op disposable container instead + } + + /** + * Returns an empty {@code Streamable} that never produces an item and just completes. + * @param the element type + * @return the {@code Streamable} instance + */ + @NonNull + public static <@NonNull T> Streamable empty() { + return new StreamableEmpty<>(); + } + + /** + * Returns a single-element {@code Streamable} that produces the constant item and completes. + * @param the element type + * @param item the constant item to produce + * @return the {@code Streamable} instance + */ + public static <@NonNull T> Streamable just(@NonNull T item) { + Objects.requireNonNull(item, "item is null"); + return new StreamableJust<>(item); + } + + /** + * Consumes elements from this {@code Streamable} via the provided executor service. + * @param consumer the callback that gets the elements until completion + * @return a Disposable that let's one cancel the sequence asynchronously. + */ + @NonNull + public final CompletionStageDisposable forEach(@NonNull Consumer consumer) { + CompositeDisposable canceller = new CompositeDisposable(); + return forEach(consumer, canceller, Executors.newVirtualThreadPerTaskExecutor()); + } + + /** + * Consumes elements from this {@code Streamable} via the provided executor service. + * @param consumer the callback that gets the elements until completion + * @param canceller the container to trigger cancellation of the sequence + * @return the {@code CompletionStage} that gets notified when the sequence ends + */ + public final CompletionStageDisposable forEach(@NonNull Consumer consumer, @NonNull DisposableContainer canceller) { + return forEach(consumer, canceller, Executors.newVirtualThreadPerTaskExecutor()); + } + + /** + * Consumes elements from this {@code Streamable} via the provided executor service. + * @param consumer the callback that gets the elements until completion + * @param executor the service that hosts the blocking waits. + * @return a Disposable that let's one cancel the sequence asynchronously. + */ + @NonNull + public final CompletionStageDisposable forEach(@NonNull Consumer consumer, @NonNull ExecutorService executor) { + CompositeDisposable canceller = new CompositeDisposable(); + return forEach(consumer, canceller, executor); + } + + /** + * Consumes elements from this {@code Streamable} via the provided executor service. + * @param consumer the callback that gets the elements until completion + * @param canceller the container to trigger cancellation of the sequence + * @param executor the service that hosts the blocking waits. + * @return the {@code CompletionStage} that gets notified when the sequence ends + */ + @SuppressWarnings("unchecked") + public final CompletionStageDisposable forEach(@NonNull Consumer consumer, @NonNull DisposableContainer canceller, @NonNull ExecutorService executor) { + Objects.requireNonNull(consumer, "consumer is null"); + Objects.requireNonNull(canceller, "canceller is null"); + Objects.requireNonNull(executor, "executor is null"); + final Streamable me = this; + var future = executor.submit(() -> { + try (var str = me.stream(canceller)) { + while (!canceller.isDisposed()) { + if (str.next().toCompletableFuture().join()) { + consumer.accept(Objects.requireNonNull(str.current(), "The upstream Streamable " + me.getClass() + " produced a null element!")); + } else { + break; + } + } + } catch (final Throwable crash) { + Exceptions.throwIfFatal(crash); + if (crash instanceof RuntimeException ex) { + throw ex; + } + if (crash instanceof Exception ex) { + throw ex; + } + throw new InvocationTargetException(crash); + } + return null; + }); + canceller.add(Disposable.fromFuture(future)); + return new CompletionStageDisposable(StreamableHelper.toCompletionStage((Future)(Future)future), canceller); + } + + /** + * Consume this {@code Streamable} via the given flow-reactive-streams subscriber. + * @param subscriber the subscriber to consume with. + * @param executor the service that hosts the blocking waits. + */ + public final void subscribe(@NonNull Flow.Subscriber subscriber, @NonNull ExecutorService executor) { + + } +} diff --git a/src/main/java/io/reactivex/rxjava4/core/Streamer.java b/src/main/java/io/reactivex/rxjava4/core/Streamer.java new file mode 100644 index 0000000000..2f49dd8c8b --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/core/Streamer.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.core; + +import java.util.NoSuchElementException; +import java.util.concurrent.CompletionStage; + +import io.reactivex.rxjava4.annotations.NonNull; + +/** + * 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. + * @param the element type. + * TODO proper docs + * @since 4.0.0 + */ +public interface Streamer<@NonNull T> extends AutoCloseable { + + /** + * Determine if there are more elements available from the source. + * @return eventually true or false, indicating availability or termination + */ + @NonNull + CompletionStage next(); + + /** + * Returns the current element if {@link #next()} yielded {@code true}. + * Can be called multiple times between {@link #next()} calls. + * @return the current element + * @throws NoSuchElementException before the very first {@link #next()} or after {@link #next()} returned {@code false} + */ + @NonNull + T current(); + + /** + * Called when the stream ends or gets cancelled. Should be always invoked. + * TODO, this is inherited from {@code IAsyncDisposable} in C#... + * @return the stage you can await to cleanups to happen + */ + @NonNull + CompletionStage cancel(); + + /** + * Make this Streamer a resource and a Closeable. + */ + default void close() { + cancel().toCompletableFuture().join(); + } +} diff --git a/src/main/java/io/reactivex/rxjava4/disposables/Disposable.java b/src/main/java/io/reactivex/rxjava4/disposables/Disposable.java index f04501803a..eaedde68ad 100644 --- a/src/main/java/io/reactivex/rxjava4/disposables/Disposable.java +++ b/src/main/java/io/reactivex/rxjava4/disposables/Disposable.java @@ -13,19 +13,19 @@ package io.reactivex.rxjava4.disposables; +import java.util.Objects; +import java.util.concurrent.Flow.Subscription; +import java.util.concurrent.Future; + import io.reactivex.rxjava4.annotations.NonNull; import io.reactivex.rxjava4.functions.Action; import io.reactivex.rxjava4.internal.disposables.EmptyDisposable; import io.reactivex.rxjava4.internal.functions.Functions; -import static java.util.concurrent.Flow.*; - -import java.util.Objects; -import java.util.concurrent.Future; /** * Represents a disposable resource. */ -public interface Disposable { +public interface Disposable extends AutoCloseable { /** * Dispose the resource, the operation should be idempotent. */ @@ -37,6 +37,14 @@ public interface Disposable { */ boolean isDisposed(); + /** + * Dispose the resource, the operation should be idempotent. + * @since 4.0.0 + */ + default void close() { + dispose(); + } + /** * Construct a {@code Disposable} by wrapping a {@link Runnable} that is * executed exactly once when the {@code Disposable} is disposed. diff --git a/src/main/java/io/reactivex/rxjava4/disposables/DisposableContainer.java b/src/main/java/io/reactivex/rxjava4/disposables/DisposableContainer.java index ed27abcc9f..85497e5af7 100644 --- a/src/main/java/io/reactivex/rxjava4/disposables/DisposableContainer.java +++ b/src/main/java/io/reactivex/rxjava4/disposables/DisposableContainer.java @@ -17,7 +17,7 @@ * Common interface to add and remove disposables from a container. * @since 2.0 */ -public interface DisposableContainer { +public interface DisposableContainer extends Disposable { /** * Adds a disposable to this container or disposes it if the diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCount.java b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCount.java index 3f1c8e90c7..bfd78c2b6b 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCount.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableRefCount.java @@ -91,6 +91,7 @@ protected void subscribeActual(Subscriber s) { } } + @SuppressWarnings("resource") void cancel(RefConnection rc) { SequentialDisposable sd; synchronized (this) { diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableAmb.java b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableAmb.java index 1d17cabe7f..0b0af8470b 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableAmb.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableAmb.java @@ -68,6 +68,7 @@ public void subscribeActual(Observer observer) { return; } + @SuppressWarnings("resource") AmbCoordinator ac = new AmbCoordinator<>(observer, count); ac.subscribe(sources); } diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatest.java b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatest.java index b2c8c419c1..91b97733f3 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatest.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableCombineLatest.java @@ -72,6 +72,7 @@ public void subscribeActual(Observer observer) { return; } + @SuppressWarnings("resource") LatestCoordinator lc = new LatestCoordinator<>(observer, combiner, count, bufferSize, delayError); lc.subscribe(sources); } diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCount.java b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCount.java index f999869a4f..63bf0f4382 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCount.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableRefCount.java @@ -88,6 +88,7 @@ protected void subscribeActual(Observer observer) { } } + @SuppressWarnings("resource") void cancel(RefConnection rc) { SequentialDisposable sd; synchronized (this) { diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableZip.java b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableZip.java index 0e67b46009..46585a3a88 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableZip.java +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/observable/ObservableZip.java @@ -68,6 +68,7 @@ public void subscribeActual(Observer observer) { return; } + @SuppressWarnings("resource") ZipCoordinator zc = new ZipCoordinator<>(observer, zipper, count, delayError); zc.subscribe(sources, bufferSize); } diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmpty.java b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmpty.java new file mode 100644 index 0000000000..81ab52053b --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableEmpty.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.internal.operators.streamable; + +import java.util.NoSuchElementException; +import java.util.concurrent.*; + +import io.reactivex.rxjava4.annotations.NonNull; +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.disposables.DisposableContainer; + +public final class StreamableEmpty extends Streamable { + + @Override + public @NonNull Streamer<@NonNull T> stream(@NonNull DisposableContainer cancellation) { + return new EmptyStreamer(); + } + + static final class EmptyStreamer implements Streamer { + + @Override + public @NonNull CompletionStage next() { + return CompletableFuture.completedStage(false); // TODO would constant stages work here or is that contention? + } + + @Override + public @NonNull T current() { + throw new NoSuchElementException("This Streamable/Streamer never has elements"); + } + + @Override + public @NonNull CompletionStage cancel() { + return CompletableFuture.completedStage(null); // TODO would constant stages work here or is that contention? + } + } +} diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableHelper.java b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableHelper.java new file mode 100644 index 0000000000..b815f45bdc --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableHelper.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.internal.operators.streamable; + +import java.util.concurrent.*; + +public enum StreamableHelper { + INSTANCE; + + @SuppressWarnings("unchecked") + public static CompletionStage toCompletionStage(Future future) { + if (future instanceof CompletionStage) { + return (CompletionStage) future; + } + return CompletableFuture.supplyAsync(() -> { + try { + return future.get(); + } catch (Exception e) { + throw new CompletionException(e); + } + }); + } +} diff --git a/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java new file mode 100644 index 0000000000..03bcf901b7 --- /dev/null +++ b/src/main/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableJust.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.internal.operators.streamable; + +import java.util.NoSuchElementException; +import java.util.concurrent.*; + +import io.reactivex.rxjava4.annotations.NonNull; +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.disposables.*; + +public final class StreamableJust extends Streamable { + + final T item; + + public StreamableJust(T item) { + this.item = item; + } + + @Override + public @NonNull Streamer<@NonNull T> stream(@NonNull DisposableContainer cancellation) { + return new JustStreamer(item, cancellation); + } + + static final class JustStreamer implements Streamer, Disposable { + + volatile T item; + + volatile DisposableContainer cancellation; + + volatile int stage; + + JustStreamer(T item, DisposableContainer cancellation) { + this.item = item; + this.cancellation = cancellation; + cancellation.add(this); + } + + @Override + public @NonNull CompletionStage next() { + if (stage == 0) { + stage = 1; + return CompletableFuture.completedStage(true); + } + item = null; + cancellation = null; + stage = 2; + return CompletableFuture.completedStage(false); // TODO would constant stages work here or is that contention? + } + + @Override + public @NonNull T current() { + var item = this.item; + if (stage == 0) { + throw new NoSuchElementException("Streamable.just not yet started!"); + } + if (stage == 2) { + throw new NoSuchElementException("Streamable.just already completed!"); + } + return item; + } + + @Override + public @NonNull CompletionStage cancel() { + item = null; + cancellation = null; + stage = 2; + return CompletableFuture.completedStage(null); // TODO would constant stages work here or is that contention? + } + + @Override + public void close() { + Streamer.super.close(); + } + + @Override + public boolean isDisposed() { + return stage == 2; + } + + @Override + public void dispose() { + var dc = cancellation; + if (dc != null) { + if (dc.delete(this)) { + close(); // FIXME not sure about this! + } + } + } + } +} diff --git a/src/main/java/io/reactivex/rxjava4/internal/schedulers/ExecutorScheduler.java b/src/main/java/io/reactivex/rxjava4/internal/schedulers/ExecutorScheduler.java index 91e0131050..9223605c08 100644 --- a/src/main/java/io/reactivex/rxjava4/internal/schedulers/ExecutorScheduler.java +++ b/src/main/java/io/reactivex/rxjava4/internal/schedulers/ExecutorScheduler.java @@ -166,6 +166,7 @@ public Disposable schedule(@NonNull Runnable run) { task = interruptibleTask; disposable = interruptibleTask; } else { + @SuppressWarnings("resource") BooleanRunnable runnableTask = new BooleanRunnable(decoratedRun); task = runnableTask; diff --git a/src/test/java/io/reactivex/rxjava4/completable/CompletableTest.java b/src/test/java/io/reactivex/rxjava4/completable/CompletableTest.java index 1753987af6..8479d9e5ab 100644 --- a/src/test/java/io/reactivex/rxjava4/completable/CompletableTest.java +++ b/src/test/java/io/reactivex/rxjava4/completable/CompletableTest.java @@ -1078,6 +1078,7 @@ public void onError(Throwable e) { public void timerCancel() throws InterruptedException { Completable c = Completable.timer(250, TimeUnit.MILLISECONDS); + @SuppressWarnings("resource") final SequentialDisposable sd = new SequentialDisposable(); final AtomicInteger calls = new AtomicInteger(); diff --git a/src/test/java/io/reactivex/rxjava4/core/DisposeTaskTest.java b/src/test/java/io/reactivex/rxjava4/core/DisposeTaskTest.java index efdea61a1b..6cfae35631 100644 --- a/src/test/java/io/reactivex/rxjava4/core/DisposeTaskTest.java +++ b/src/test/java/io/reactivex/rxjava4/core/DisposeTaskTest.java @@ -31,6 +31,7 @@ public void runnableThrows() throws Throwable { Scheduler.Worker worker = Schedulers.single().createWorker(); + @SuppressWarnings("resource") DisposeTask task = new DisposeTask(() -> { throw new TestException(); }, worker); diff --git a/src/test/java/io/reactivex/rxjava4/core/PeriodicDirectTaskTest.java b/src/test/java/io/reactivex/rxjava4/core/PeriodicDirectTaskTest.java index c7244baf9b..3f7c32ff5f 100644 --- a/src/test/java/io/reactivex/rxjava4/core/PeriodicDirectTaskTest.java +++ b/src/test/java/io/reactivex/rxjava4/core/PeriodicDirectTaskTest.java @@ -34,6 +34,7 @@ public void runnableThrows() { try { Scheduler.Worker worker = Schedulers.single().createWorker(); + @SuppressWarnings("resource") PeriodicDirectTask task = new PeriodicDirectTask(() -> { throw new TestException(); }, worker); diff --git a/src/test/java/io/reactivex/rxjava4/disposables/CompositeDisposableTest.java b/src/test/java/io/reactivex/rxjava4/disposables/CompositeDisposableTest.java index 5675f6a4b8..f17b2683e3 100644 --- a/src/test/java/io/reactivex/rxjava4/disposables/CompositeDisposableTest.java +++ b/src/test/java/io/reactivex/rxjava4/disposables/CompositeDisposableTest.java @@ -29,6 +29,7 @@ public class CompositeDisposableTest extends RxJavaTest { + @SuppressWarnings("resource") @Test public void success() { final AtomicInteger counter = new AtomicInteger(); @@ -55,6 +56,7 @@ public void run() { assertEquals(2, counter.get()); } + @SuppressWarnings("resource") @Test public void shouldUnsubscribeAll() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(); @@ -100,6 +102,7 @@ public void run() { @Test public void exception() { final AtomicInteger counter = new AtomicInteger(); + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromRunnable(new Runnable() { @@ -134,6 +137,7 @@ public void run() { @Test public void compositeException() { final AtomicInteger counter = new AtomicInteger(); + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromRunnable(new Runnable() { @@ -178,6 +182,7 @@ public void removeUnsubscribes() { Disposable d1 = Disposable.empty(); Disposable d2 = Disposable.empty(); + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(d1); cd.add(d2); @@ -193,6 +198,7 @@ public void clear() { Disposable d1 = Disposable.empty(); Disposable d2 = Disposable.empty(); + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(d1); cd.add(d2); @@ -218,6 +224,7 @@ public void clear() { @Test public void unsubscribeIdempotence() { final AtomicInteger counter = new AtomicInteger(); + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromRunnable(new Runnable() { @@ -240,6 +247,7 @@ public void run() { public void unsubscribeIdempotenceConcurrently() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(); + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final int count = 10; @@ -281,6 +289,7 @@ public void run() { @Test public void tryRemoveIfNotIn() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); CompositeDisposable cd1 = new CompositeDisposable(); @@ -295,10 +304,12 @@ public void tryRemoveIfNotIn() { @Test(expected = NullPointerException.class) public void addingNullDisposableIllegal() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(null); } + @SuppressWarnings("resource") @Test public void initializeVarargs() { Disposable d1 = Disposable.empty(); @@ -328,6 +339,7 @@ public void initializeVarargs() { assertEquals(0, cd.size()); } + @SuppressWarnings("resource") @Test public void initializeIterable() { Disposable d1 = Disposable.empty(); @@ -359,6 +371,7 @@ public void initializeIterable() { assertEquals(0, cd.size()); } + @SuppressWarnings("resource") @Test public void addAll() { CompositeDisposable cd = new CompositeDisposable(); @@ -403,6 +416,7 @@ public void addAll() { @Test public void addAfterDisposed() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.dispose(); @@ -425,6 +439,7 @@ public void addAfterDisposed() { @Test public void delete() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); Disposable d1 = Disposable.empty(); @@ -445,6 +460,7 @@ public void delete() { @Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @@ -461,6 +477,7 @@ public void run() { @Test public void addRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @@ -477,6 +494,7 @@ public void run() { @Test public void addAllRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @@ -493,6 +511,7 @@ public void run() { @Test public void removeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -513,6 +532,7 @@ public void run() { @Test public void deleteRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -533,6 +553,7 @@ public void run() { @Test public void clearRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -553,6 +574,7 @@ public void run() { @Test public void addDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @@ -576,6 +598,7 @@ public void run() { @Test public void addAllDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); Runnable run = new Runnable() { @@ -599,6 +622,7 @@ public void run() { @Test public void removeDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -626,6 +650,7 @@ public void run() { @Test public void deleteDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -653,6 +678,7 @@ public void run() { @Test public void clearDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -680,6 +706,7 @@ public void run() { @Test public void sizeDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable cd = new CompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -706,6 +733,7 @@ public void run() { @Test public void disposeThrowsIAE() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromAction(new Action() { @@ -731,6 +759,7 @@ public void run() throws Exception { @Test public void disposeThrowsError() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromAction(new Action() { @@ -756,6 +785,7 @@ public void run() throws Exception { @Test public void disposeThrowsCheckedException() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(Disposable.fromAction(new Action() { @@ -789,6 +819,7 @@ static void throwSneaky() throws E { @Test public void disposeThrowsCheckedExceptionSneaky() { + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); cd.add(new Disposable() { diff --git a/src/test/java/io/reactivex/rxjava4/disposables/FutureDisposableTest.java b/src/test/java/io/reactivex/rxjava4/disposables/FutureDisposableTest.java index 50da24c817..f087d659ed 100644 --- a/src/test/java/io/reactivex/rxjava4/disposables/FutureDisposableTest.java +++ b/src/test/java/io/reactivex/rxjava4/disposables/FutureDisposableTest.java @@ -61,6 +61,7 @@ public void interruptible() { @Test public void normalDone() { FutureTask ft = new FutureTask<>(Functions.EMPTY_RUNNABLE, null); + @SuppressWarnings("resource") FutureDisposable d = new FutureDisposable(ft, false); assertFalse(d.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/disposables/SerialDisposableTests.java b/src/test/java/io/reactivex/rxjava4/disposables/SerialDisposableTests.java index 84f83854a3..a3847c9bb6 100644 --- a/src/test/java/io/reactivex/rxjava4/disposables/SerialDisposableTests.java +++ b/src/test/java/io/reactivex/rxjava4/disposables/SerialDisposableTests.java @@ -207,6 +207,7 @@ public void run() { @Test public void disposeState() { Disposable empty = Disposable.empty(); + @SuppressWarnings("resource") SerialDisposable d = new SerialDisposable(empty); assertFalse(d.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/flowable/FlowableSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/flowable/FlowableSubscriberTest.java index 81768f011d..f635ae14da 100644 --- a/src/test/java/io/reactivex/rxjava4/flowable/FlowableSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/flowable/FlowableSubscriberTest.java @@ -543,6 +543,7 @@ public boolean test(Integer v) throws Exception { @Test public void doubleSubscribe() { + @SuppressWarnings("resource") ForEachWhileSubscriber s = new ForEachWhileSubscriber<>(new Predicate() { @Override public boolean test(Integer v) throws Exception { @@ -573,6 +574,7 @@ public void suppressAfterCompleteEvents() { final TestSubscriber ts = new TestSubscriber<>(); ts.onSubscribe(new BooleanSubscription()); + @SuppressWarnings("resource") ForEachWhileSubscriber s = new ForEachWhileSubscriber<>(new Predicate() { @Override public boolean test(Integer v) throws Exception { @@ -609,6 +611,7 @@ public void onNextCrashes() { final TestSubscriber ts = new TestSubscriber<>(); ts.onSubscribe(new BooleanSubscription()); + @SuppressWarnings("resource") ForEachWhileSubscriber s = new ForEachWhileSubscriber<>(new Predicate() { @Override public boolean test(Integer v) throws Exception { @@ -637,6 +640,7 @@ public void run() throws Exception { @Test public void onErrorThrows() { + @SuppressWarnings("resource") ForEachWhileSubscriber s = new ForEachWhileSubscriber<>(new Predicate() { @Override public boolean test(Integer v) throws Exception { @@ -672,6 +676,7 @@ public void run() throws Exception { @Test public void onCompleteThrows() { + @SuppressWarnings("resource") ForEachWhileSubscriber s = new ForEachWhileSubscriber<>(new Predicate() { @Override public boolean test(Integer v) throws Exception { diff --git a/src/test/java/io/reactivex/rxjava4/internal/disposables/ArrayCompositeDisposableTest.java b/src/test/java/io/reactivex/rxjava4/internal/disposables/ArrayCompositeDisposableTest.java index 35b5127e39..e7941aaf85 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/disposables/ArrayCompositeDisposableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/disposables/ArrayCompositeDisposableTest.java @@ -23,6 +23,7 @@ public class ArrayCompositeDisposableTest extends RxJavaTest { + @SuppressWarnings("resource") @Test public void normal() { ArrayCompositeDisposable acd = new ArrayCompositeDisposable(2); @@ -68,6 +69,7 @@ public void normal() { assertTrue(d6.isDisposed()); } + @SuppressWarnings("resource") @Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { @@ -84,6 +86,7 @@ public void run() { } } + @SuppressWarnings("resource") @Test public void replaceRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { @@ -100,6 +103,7 @@ public void run() { } } + @SuppressWarnings("resource") @Test public void setRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/disposables/CancellableDisposableTest.java b/src/test/java/io/reactivex/rxjava4/internal/disposables/CancellableDisposableTest.java index 6212b39ad2..8721f3ee0c 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/disposables/CancellableDisposableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/disposables/CancellableDisposableTest.java @@ -39,6 +39,7 @@ public void cancel() throws Exception { } }; + @SuppressWarnings("resource") CancellableDisposable cd = new CancellableDisposable(c); assertFalse(cd.isDisposed()); @@ -63,6 +64,7 @@ public void cancel() throws Exception { } }; + @SuppressWarnings("resource") CancellableDisposable cd = new CancellableDisposable(c); assertFalse(cd.isDisposed()); @@ -94,6 +96,7 @@ public void cancel() throws Exception { } }; + @SuppressWarnings("resource") final CancellableDisposable cd = new CancellableDisposable(c); Runnable r = new Runnable() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/disposables/ListCompositeDisposableTest.java b/src/test/java/io/reactivex/rxjava4/internal/disposables/ListCompositeDisposableTest.java index 3841796aa7..679ff9d423 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/disposables/ListCompositeDisposableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/disposables/ListCompositeDisposableTest.java @@ -31,6 +31,7 @@ public void constructorAndAddVarargs() { Disposable d1 = Disposable.empty(); Disposable d2 = Disposable.empty(); + @SuppressWarnings("resource") ListCompositeDisposable lcd = new ListCompositeDisposable(d1, d2); lcd.clear(); @@ -57,6 +58,7 @@ public void constructorIterable() { Disposable d1 = Disposable.empty(); Disposable d2 = Disposable.empty(); + @SuppressWarnings("resource") ListCompositeDisposable lcd = new ListCompositeDisposable(Arrays.asList(d1, d2)); lcd.clear(); @@ -81,6 +83,7 @@ public void constructorIterable() { @Test public void empty() { + @SuppressWarnings("resource") ListCompositeDisposable lcd = new ListCompositeDisposable(); assertFalse(lcd.isDisposed()); @@ -100,6 +103,7 @@ public void empty() { @Test public void afterDispose() { + @SuppressWarnings("resource") ListCompositeDisposable lcd = new ListCompositeDisposable(); lcd.dispose(); @@ -112,6 +116,7 @@ public void afterDispose() { assertTrue(d.isDisposed()); } + @SuppressWarnings("resource") @Test public void disposeThrows() { Disposable d = new Disposable() { @@ -149,6 +154,7 @@ public boolean isDisposed() { } } + @SuppressWarnings("resource") @Test public void remove() { ListCompositeDisposable lcd = new ListCompositeDisposable(); @@ -180,6 +186,7 @@ public void remove() { @Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @@ -196,6 +203,7 @@ public void run() { @Test public void addRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @@ -212,6 +220,7 @@ public void run() { @Test public void addAllRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @@ -228,6 +237,7 @@ public void run() { @Test public void removeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -248,6 +258,7 @@ public void run() { @Test public void deleteRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -268,6 +279,7 @@ public void run() { @Test public void clearRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -288,6 +300,7 @@ public void run() { @Test public void addDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @@ -311,6 +324,7 @@ public void run() { @Test public void addAllDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); Runnable run = new Runnable() { @@ -334,6 +348,7 @@ public void run() { @Test public void removeDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -361,6 +376,7 @@ public void run() { @Test public void deleteDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); @@ -388,6 +404,7 @@ public void run() { @Test public void clearDisposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final ListCompositeDisposable cd = new ListCompositeDisposable(); final Disposable d1 = Disposable.empty(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/fuseable/CancellableQueueFuseableTest.java b/src/test/java/io/reactivex/rxjava4/internal/fuseable/CancellableQueueFuseableTest.java index babf0e05d1..96116ba28e 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/fuseable/CancellableQueueFuseableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/fuseable/CancellableQueueFuseableTest.java @@ -27,6 +27,7 @@ public void offer() { @Test public void pollClear() throws Throwable { + @SuppressWarnings("resource") CancellableQueueFuseable qs = new CancellableQueueFuseable<>(); assertNull(qs.poll()); @@ -37,6 +38,7 @@ public void pollClear() throws Throwable { @Test public void cancel() { + @SuppressWarnings("resource") CancellableQueueFuseable qs = new CancellableQueueFuseable<>(); assertFalse(qs.isDisposed()); @@ -52,6 +54,7 @@ public void cancel() { @Test public void dispose() { + @SuppressWarnings("resource") CancellableQueueFuseable qs = new CancellableQueueFuseable<>(); assertFalse(qs.isDisposed()); @@ -67,6 +70,7 @@ public void dispose() { @Test public void cancel2() { + @SuppressWarnings("resource") AbstractEmptyQueueFuseable qs = new AbstractEmptyQueueFuseable() { }; assertFalse(qs.isDisposed()); @@ -76,6 +80,7 @@ public void cancel2() { @Test public void dispose2() { + @SuppressWarnings("resource") AbstractEmptyQueueFuseable qs = new AbstractEmptyQueueFuseable() { }; assertFalse(qs.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/BasicFuseableObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/BasicFuseableObserverTest.java index 900d32f35a..1f6b257656 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/BasicFuseableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/BasicFuseableObserverTest.java @@ -57,6 +57,7 @@ protected boolean beforeDownstream() { @Test(expected = UnsupportedOperationException.class) public void offer2() { + @SuppressWarnings("resource") BasicFuseableObserver o = new BasicFuseableObserver(new TestObserver<>()) { @Nullable @Override diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingFirstObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingFirstObserverTest.java index d74463c9ce..9d8cda2a85 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingFirstObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingFirstObserverTest.java @@ -23,6 +23,7 @@ public class BlockingFirstObserverTest extends RxJavaTest { + @SuppressWarnings("resource") @Test public void firstValueOnly() { BlockingFirstObserver bf = new BlockingFirstObserver<>(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingObserverTest.java index cb0eb0df46..cb0177d85e 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/BlockingObserverTest.java @@ -23,6 +23,7 @@ public class BlockingObserverTest extends RxJavaTest { + @SuppressWarnings("resource") @Test public void dispose() { Queue q = new ArrayDeque<>(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/CallbackCompletableObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/CallbackCompletableObserverTest.java index 2d67997c83..28948a8b7a 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/CallbackCompletableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/CallbackCompletableObserverTest.java @@ -24,6 +24,7 @@ public final class CallbackCompletableObserverTest extends RxJavaTest { @Test public void emptyActionShouldReportNoCustomOnError() { + @SuppressWarnings("resource") CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); assertFalse(o.hasCustomOnError()); @@ -31,6 +32,7 @@ public void emptyActionShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.emptyConsumer(), Functions.EMPTY_ACTION); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/ConsumerSingleObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/ConsumerSingleObserverTest.java index 718312f8de..9b830b4f9b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/ConsumerSingleObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/ConsumerSingleObserverTest.java @@ -24,6 +24,7 @@ public final class ConsumerSingleObserverTest extends RxJavaTest { @Test public void onErrorMissingShouldReportNoCustomOnError() { + @SuppressWarnings("resource") ConsumerSingleObserver o = new ConsumerSingleObserver<>(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING); @@ -32,6 +33,7 @@ public void onErrorMissingShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") ConsumerSingleObserver o = new ConsumerSingleObserver<>(Functions.emptyConsumer(), Functions.emptyConsumer()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/DeferredScalarObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/DeferredScalarObserverTest.java index bec056e277..e6a5058275 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/DeferredScalarObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/DeferredScalarObserverTest.java @@ -53,6 +53,7 @@ public void normal() { try { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); source.onSubscribe(Disposable.empty()); @@ -76,6 +77,7 @@ public void normal() { public void error() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); source.onSubscribe(Disposable.empty()); @@ -88,6 +90,7 @@ public void error() { public void complete() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); source.onSubscribe(Disposable.empty()); @@ -100,6 +103,7 @@ public void complete() { public void dispose() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); Disposable d = Disposable.empty(); @@ -121,6 +125,7 @@ public void fused() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.ANY); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); Disposable d = Disposable.empty(); @@ -151,6 +156,7 @@ public void fusedReject() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.SYNC); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(to); Disposable d = Disposable.empty(); @@ -196,6 +202,7 @@ public void nonfusedTerminateMore() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.NONE); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -221,6 +228,7 @@ public void nonfusedError() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.NONE); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -246,6 +254,7 @@ public void fusedTerminateMore() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.ANY); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -271,6 +280,7 @@ public void fusedError() { try { TestObserverEx to = new TestObserverEx<>(QueueFuseable.ANY); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -294,6 +304,7 @@ public void fusedError() { public void disposed() { TestObserverEx to = new TestObserverEx<>(QueueFuseable.NONE); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -310,8 +321,10 @@ public void disposed() { @Test public void disposedAfterOnNext() { + @SuppressWarnings("resource") final TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeLast source = new TakeLast(new Observer() { Disposable upstream; @@ -349,6 +362,7 @@ public void onComplete() { public void fusedEmpty() { TestObserverEx to = new TestObserverEx<>(QueueFuseable.ANY); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -364,6 +378,7 @@ public void fusedEmpty() { public void nonfusedEmpty() { TestObserverEx to = new TestObserverEx<>(QueueFuseable.NONE); + @SuppressWarnings("resource") TakeLast source = new TakeLast(to); Disposable d = Disposable.empty(); @@ -377,8 +392,10 @@ public void nonfusedEmpty() { @Test public void customFusion() { + @SuppressWarnings("resource") final TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeLast source = new TakeLast(new Observer() { QueueDisposable d; @@ -427,8 +444,10 @@ public void onComplete() { @Test public void customFusionClear() { + @SuppressWarnings("resource") final TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeLast source = new TakeLast(new Observer() { QueueDisposable d; @@ -475,8 +494,10 @@ public void offerThrow() { @Test public void customFusionDontConsume() { + @SuppressWarnings("resource") final TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") TakeFirst source = new TakeFirst(new Observer() { QueueDisposable d; diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/DisposableLambdaObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/DisposableLambdaObserverTest.java index 20680ad211..7604909c82 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/DisposableLambdaObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/DisposableLambdaObserverTest.java @@ -41,6 +41,7 @@ public void doubleOnSubscribe() { public void disposeCrash() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") DisposableLambdaObserver o = new DisposableLambdaObserver<>( new TestObserver<>(), Functions.emptyConsumer(), new Action() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/EmptyCompletableObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/EmptyCompletableObserverTest.java index bd8d8769ca..457570389b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/EmptyCompletableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/EmptyCompletableObserverTest.java @@ -23,6 +23,7 @@ public final class EmptyCompletableObserverTest extends RxJavaTest { @Test public void defaultShouldReportNoCustomOnError() { + @SuppressWarnings("resource") EmptyCompletableObserver o = new EmptyCompletableObserver(); assertFalse(o.hasCustomOnError()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/FutureMultiObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/FutureMultiObserverTest.java index 0d04e1560f..9ad1596133 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/FutureMultiObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/FutureMultiObserverTest.java @@ -23,6 +23,7 @@ public class FutureMultiObserverTest extends RxJavaTest { @Test public void cancelBeforeOnSubscribe() { + @SuppressWarnings("resource") FutureMultiObserver f = new FutureMultiObserver<>(); assertTrue(f.cancel(true)); @@ -36,6 +37,7 @@ public void cancelBeforeOnSubscribe() { @Test public void onCompleteJustAfterDispose() { + @SuppressWarnings("resource") FutureMultiObserver f = new FutureMultiObserver<>(); Disposable d = Disposable.empty(); f.onSubscribe(d); diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/FutureObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/FutureObserverTest.java index c655943206..105808d554 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/FutureObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/FutureObserverTest.java @@ -155,6 +155,7 @@ public void onSubscribe() throws Exception { @Test public void cancelRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final FutureObserver fo = new FutureObserver<>(); Runnable r = new Runnable() { @@ -186,6 +187,7 @@ public void onErrorCancelRace() { RxJavaPlugins.setErrorHandler(Functions.emptyConsumer()); try { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final FutureObserver fo = new FutureObserver<>(); final TestException ex = new TestException(); @@ -216,6 +218,7 @@ public void onCompleteCancelRace() { RxJavaPlugins.setErrorHandler(Functions.emptyConsumer()); try { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final FutureObserver fo = new FutureObserver<>(); if (i % 3 == 0) { @@ -382,6 +385,7 @@ public void getTimedOut() throws Exception { @Test public void cancelOnSubscribeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final FutureObserver fo = new FutureObserver<>(); Runnable r = new Runnable() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/observers/LambdaObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/observers/LambdaObserverTest.java index 9fa90ad511..38401c9b8a 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/observers/LambdaObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/observers/LambdaObserverTest.java @@ -363,6 +363,7 @@ public void accept(Disposable d) throws Exception { @Test public void onErrorMissingShouldReportNoCustomOnError() { + @SuppressWarnings("resource") LambdaObserver o = new LambdaObserver<>(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION, @@ -373,6 +374,7 @@ public void onErrorMissingShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") LambdaObserver o = new LambdaObserver<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, @@ -387,6 +389,7 @@ public void disposedObserverShouldReportErrorOnGlobalErrorHandler() { try { final List observerErrors = Collections.synchronizedList(new ArrayList<>()); + @SuppressWarnings("resource") LambdaObserver o = new LambdaObserver<>(Functions.emptyConsumer(), new Consumer() { @Override diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableCacheTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableCacheTest.java index 12dabaf391..f3f2ed47fb 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableCacheTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/completable/CompletableCacheTest.java @@ -237,6 +237,7 @@ public void run() { public void doubleDispose() { PublishSubject ps = PublishSubject.create(); + @SuppressWarnings("resource") final TestObserver to = new TestObserver<>(); ps.ignoreElements().cache() diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableNextTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableNextTest.java index 65a81fe17b..e5196f7b25 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableNextTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableNextTest.java @@ -232,6 +232,7 @@ public void nextWithCallingHasNextMultipleTimes() { public void noBufferingOrBlockingOfSequence() throws Throwable { int repeat = 0; for (;;) { + @SuppressWarnings("resource") final SerialDisposable task = new SerialDisposable(); try { final CountDownLatch finished = new CountDownLatch(1); @@ -352,6 +353,7 @@ public void interrupt() { @Test public void nextObserverError() { + @SuppressWarnings("resource") NextSubscriber no = new NextSubscriber<>(); List errors = TestHelper.trackPluginErrors(); @@ -366,6 +368,7 @@ public void nextObserverError() { @Test public void nextObserverOnNext() throws Exception { + @SuppressWarnings("resource") NextSubscriber no = new NextSubscriber<>(); no.setWaiting(); @@ -379,6 +382,7 @@ public void nextObserverOnNext() throws Exception { @Test public void nextObserverOnCompleteOnNext() throws Exception { + @SuppressWarnings("resource") NextSubscriber no = new NextSubscriber<>(); no.setWaiting(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableToIteratorTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableToIteratorTest.java index 3f06db0fc1..7532d9cca6 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableToIteratorTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/BlockingFlowableToIteratorTest.java @@ -117,12 +117,14 @@ public void remove() { @Test(expected = UnsupportedOperationException.class) public void remove() { + @SuppressWarnings("resource") BlockingFlowableIterator it = new BlockingFlowableIterator<>(128); it.remove(); } @Test public void dispose() { + @SuppressWarnings("resource") BlockingFlowableIterator it = new BlockingFlowableIterator<>(128); assertFalse(it.isDisposed()); @@ -134,6 +136,7 @@ public void dispose() { @Test public void interruptWait() { + @SuppressWarnings("resource") BlockingFlowableIterator it = new BlockingFlowableIterator<>(128); try { @@ -147,6 +150,7 @@ public void interruptWait() { @Test(expected = NoSuchElementException.class) public void emptyThrowsNoSuch() { + @SuppressWarnings("resource") BlockingFlowableIterator it = new BlockingFlowableIterator<>(128); it.onComplete(); it.next(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableAmbTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableAmbTest.java index 245bf03a09..bb6421ac51 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableAmbTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableAmbTest.java @@ -55,6 +55,7 @@ private Flowable createFlowable(final String[] values, @Override public void subscribe(final Subscriber subscriber) { + @SuppressWarnings("resource") final CompositeDisposable parentSubscription = new CompositeDisposable(); subscriber.onSubscribe(new Subscription() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableBufferTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableBufferTest.java index bd92229836..df96ee992b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableBufferTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableBufferTest.java @@ -2255,6 +2255,7 @@ public void timedInternalState() { TestSubscriber> ts = new TestSubscriber<>(); + @SuppressWarnings("resource") BufferExactUnboundedSubscriber> sub = new BufferExactUnboundedSubscriber<>( ts, Functions.justSupplier((List) new ArrayList()), 1, TimeUnit.SECONDS, sch); @@ -2350,6 +2351,7 @@ public void timedSizeBufferAlreadyCleared() { TestSubscriber> ts = new TestSubscriber<>(); + @SuppressWarnings("resource") BufferExactBoundedSubscriber> sub = new BufferExactBoundedSubscriber<>( ts, Functions.justSupplier((List) new ArrayList()), diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDebounceTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDebounceTest.java index bb69a2fccd..1b669c838e 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDebounceTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDebounceTest.java @@ -401,6 +401,7 @@ public void dispose() { TestHelper.checkDisposed(PublishProcessor.create().debounce(Functions.justFunction(Flowable.never()))); + @SuppressWarnings("resource") Disposable d = new FlowableDebounceTimed.DebounceEmitter<>(1, 1, null); assertFalse(d.isDisposed()); @@ -605,6 +606,7 @@ public void timedLateEmit() { sub.onSubscribe(new BooleanSubscription()); + @SuppressWarnings("resource") DebounceEmitter de = new DebounceEmitter<>(1, 50, sub); de.emit(); de.emit(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDelayTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDelayTest.java index c9fd09146d..ff424a7af6 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDelayTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableDelayTest.java @@ -1037,6 +1037,7 @@ public Publisher apply(Integer t) throws Exception { public void cancelShouldPreventRandomSubsequentEmissions() { for (int attempt = 1; attempt < 100; attempt ++) { + @SuppressWarnings("resource") SequentialDisposable disposable = new SequentialDisposable(); ConcurrentLinkedQueue sink = new ConcurrentLinkedQueue<>(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableFlatMapTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableFlatMapTest.java index cb4890d0bb..237ecbe343 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableFlatMapTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableFlatMapTest.java @@ -1157,6 +1157,7 @@ public void innerErrorsMainCancelled() { @Test public void innerIsDisposed() { + @SuppressWarnings("resource") FlowableFlatMap.InnerSubscriber inner = new FlowableFlatMap.InnerSubscriber<>(null, 10, 0L); assertFalse(inner.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableGroupJoinTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableGroupJoinTest.java index b3aeb96e2f..5ecaf427cd 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableGroupJoinTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableGroupJoinTest.java @@ -700,6 +700,7 @@ public Flowable apply(Object r, Flowable l) throws Exception { public void leftRightState() { JoinSupport js = mock(JoinSupport.class); + @SuppressWarnings("resource") LeftRightSubscriber o = new LeftRightSubscriber(js, false); assertFalse(o.isDisposed()); 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 389e6879b6..17ede43718 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 @@ -1262,6 +1262,7 @@ public boolean isDisposed() { } } + @SuppressWarnings("resource") @Test public void doubleOnX() { List errors = TestHelper.trackPluginErrors(); @@ -1278,6 +1279,7 @@ public void doubleOnX() { } } + @SuppressWarnings("resource") @Test public void doubleOnXCount() { List errors = TestHelper.trackPluginErrors(); @@ -1294,6 +1296,7 @@ public void doubleOnXCount() { } } + @SuppressWarnings("resource") @Test public void doubleOnXTime() { List errors = TestHelper.trackPluginErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java index 359d2a49ba..ba5ec386f2 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java @@ -898,6 +898,7 @@ protected void subscribeActual(Subscriber s) { @Test public void timeoutConsumerIsDisposed() { + @SuppressWarnings("resource") TimeoutConsumer consumer = new TimeoutConsumer(0, null); assertFalse(consumer.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCallbackObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCallbackObserverTest.java index af7d9c962b..dbd14e0def 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCallbackObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCallbackObserverTest.java @@ -31,6 +31,7 @@ public class MaybeCallbackObserverTest extends RxJavaTest { @Test public void dispose() { + @SuppressWarnings("resource") MaybeCallbackObserver mo = new MaybeCallbackObserver<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION); Disposable d = Disposable.empty(); @@ -50,6 +51,7 @@ public void dispose() { public void onSuccessCrashes() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") MaybeCallbackObserver mo = new MaybeCallbackObserver<>( new Consumer() { @Override @@ -74,6 +76,7 @@ public void accept(Object v) throws Exception { public void onErrorCrashes() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") MaybeCallbackObserver mo = new MaybeCallbackObserver<>( Functions.emptyConsumer(), new Consumer() { @@ -103,6 +106,7 @@ public void accept(Object v) throws Exception { public void onCompleteCrashes() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") MaybeCallbackObserver mo = new MaybeCallbackObserver<>( Functions.emptyConsumer(), Functions.emptyConsumer(), @@ -125,6 +129,7 @@ public void run() throws Exception { @Test public void onErrorMissingShouldReportNoCustomOnError() { + @SuppressWarnings("resource") MaybeCallbackObserver o = new MaybeCallbackObserver<>(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION); @@ -134,6 +139,7 @@ public void onErrorMissingShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") MaybeCallbackObserver o = new MaybeCallbackObserver<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapMaybeTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapMaybeTest.java index 522bca24d9..8f199d34e7 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapMaybeTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapMaybeTest.java @@ -374,6 +374,7 @@ public void scalarEmptySource() { @Test public void cancelNoConcurrentClean() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") ConcatMapMaybeMainObserver operator = new ConcatMapMaybeMainObserver<>( to, Functions.justFunction(Maybe.never()), 16, ErrorMode.IMMEDIATE); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapSingleTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapSingleTest.java index 4ba07868bb..f761c419d1 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapSingleTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/mixed/ObservableConcatMapSingleTest.java @@ -314,6 +314,7 @@ public void scalarEmptySource() { @Test public void cancelNoConcurrentClean() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") ConcatMapSingleMainObserver operator = new ConcatMapSingleMainObserver<>( to, Functions.justFunction(Single.never()), 16, ErrorMode.IMMEDIATE); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableNextTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableNextTest.java index ef1f9bc0a3..36cf08a196 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableNextTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableNextTest.java @@ -236,6 +236,7 @@ public void nextWithCallingHasNextMultipleTimes() { public void noBufferingOrBlockingOfSequence() throws Throwable { int repeat = 0; for (;;) { + @SuppressWarnings("resource") final SerialDisposable task = new SerialDisposable(); try { final CountDownLatch finished = new CountDownLatch(1); @@ -356,6 +357,7 @@ public void remove() { @Test public void nextObserverError() { + @SuppressWarnings("resource") NextObserver no = new NextObserver<>(); List errors = TestHelper.trackPluginErrors(); @@ -370,6 +372,7 @@ public void nextObserverError() { @Test public void nextObserverOnNext() throws Exception { + @SuppressWarnings("resource") NextObserver no = new NextObserver<>(); no.setWaiting(); @@ -383,6 +386,7 @@ public void nextObserverOnNext() throws Exception { @Test public void nextObserverOnCompleteOnNext() throws Exception { + @SuppressWarnings("resource") NextObserver no = new NextObserver<>(); no.setWaiting(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableToIteratorTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableToIteratorTest.java index 3e44e156ea..7ab2e806cd 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableToIteratorTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/BlockingObservableToIteratorTest.java @@ -73,6 +73,7 @@ public void subscribe(Observer observer) { @Test public void dispose() { + @SuppressWarnings("resource") BlockingObservableIterator it = new BlockingObservableIterator<>(128); assertFalse(it.isDisposed()); @@ -84,6 +85,7 @@ public void dispose() { @Test public void interruptWait() { + @SuppressWarnings("resource") BlockingObservableIterator it = new BlockingObservableIterator<>(128); try { @@ -97,6 +99,7 @@ public void interruptWait() { @Test(expected = NoSuchElementException.class) public void emptyThrowsNoSuch() { + @SuppressWarnings("resource") BlockingObservableIterator it = new BlockingObservableIterator<>(128); it.onComplete(); it.next(); @@ -104,6 +107,7 @@ public void emptyThrowsNoSuch() { @Test(expected = UnsupportedOperationException.class) public void remove() { + @SuppressWarnings("resource") BlockingObservableIterator it = new BlockingObservableIterator<>(128); it.remove(); } diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBlockingTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBlockingTest.java index 6939ffe233..aa5431071d 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBlockingTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBlockingTest.java @@ -288,6 +288,7 @@ public void onCompleteDelayed() { @Test public void blockingCancelUpfront() { + @SuppressWarnings("resource") BlockingFirstObserver o = new BlockingFirstObserver<>(); assertFalse(o.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBufferTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBufferTest.java index dffed9f381..2d8ca35406 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBufferTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableBufferTest.java @@ -1616,6 +1616,7 @@ public void timedInternalState() { TestObserver> to = new TestObserver<>(); + @SuppressWarnings("resource") BufferExactUnboundedObserver> sub = new BufferExactUnboundedObserver<>( to, Functions.justSupplier((List) new ArrayList()), 1, TimeUnit.SECONDS, sch); @@ -1666,6 +1667,7 @@ public void timedSkipInternalState() { TestObserver> to = new TestObserver<>(); + @SuppressWarnings("resource") BufferSkipBoundedObserver> sub = new BufferSkipBoundedObserver<>( to, Functions.justSupplier((List) new ArrayList()), 1, 1, TimeUnit.SECONDS, sch.createWorker()); @@ -1685,6 +1687,7 @@ public void timedSkipCancelWhenSecondBuffer() { final TestObserver> to = new TestObserver<>(); + @SuppressWarnings("resource") BufferSkipBoundedObserver> sub = new BufferSkipBoundedObserver<>( to, new Supplier>() { int calls; @@ -1711,6 +1714,7 @@ public void timedSizeBufferAlreadyCleared() { TestObserver> to = new TestObserver<>(); + @SuppressWarnings("resource") BufferExactBoundedObserver> sub = new BufferExactBoundedObserver<>( to, Functions.justSupplier((List) new ArrayList()), @@ -1754,6 +1758,7 @@ public ObservableSource> apply(Observable o) public void bufferExactState() { TestObserver> to = new TestObserver<>(); + @SuppressWarnings("resource") BufferExactObserver> sub = new BufferExactObserver<>( to, 1, Functions.justSupplier((List) new ArrayList()) ); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDebounceTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDebounceTest.java index 05d3a398c4..3bbe7ac58b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDebounceTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDebounceTest.java @@ -388,6 +388,7 @@ public void dispose() { TestHelper.checkDisposed(PublishSubject.create().debounce(Functions.justFunction(Observable.never()))); + @SuppressWarnings("resource") Disposable d = new ObservableDebounceTimed.DebounceEmitter<>(1, 1, null); assertFalse(d.isDisposed()); @@ -564,6 +565,7 @@ public void timedLateEmit() { sub.onSubscribe(Disposable.empty()); + @SuppressWarnings("resource") DebounceEmitter de = new DebounceEmitter<>(1, 50, sub); de.run(); de.run(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDelayTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDelayTest.java index 72c4361e47..a18d80580a 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDelayTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableDelayTest.java @@ -985,6 +985,7 @@ public Observable apply(Integer t) throws Exception { public void cancelShouldPreventRandomSubsequentEmissions() { for (int attempt = 1; attempt < 100; attempt ++) { + @SuppressWarnings("resource") SequentialDisposable disposable = new SequentialDisposable(); ConcurrentLinkedQueue sink = new ConcurrentLinkedQueue<>(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableFlatMapTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableFlatMapTest.java index 600dd9508a..4ac81d1fba 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableFlatMapTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableFlatMapTest.java @@ -976,6 +976,7 @@ public void fusedSourceCrashResumeWithNextSource() { final UnicastSubject fusedSource = UnicastSubject.create(); TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") ObservableFlatMap.MergeObserver merger = new ObservableFlatMap.MergeObserver<>(to, new Function>() { @Override diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableGroupJoinTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableGroupJoinTest.java index 5c45e3b3bb..1f94127578 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableGroupJoinTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableGroupJoinTest.java @@ -695,6 +695,7 @@ public Observable apply(Object r, Observable l) throws Exception public void leftRightState() { JoinSupport js = mock(JoinSupport.class); + @SuppressWarnings("resource") LeftRightObserver o = new LeftRightObserver(js, false); assertFalse(o.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMapNotificationTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMapNotificationTest.java index 1b90ed6622..f0259af396 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMapNotificationTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableMapNotificationTest.java @@ -61,6 +61,7 @@ public void dispose() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected void subscribeActual(Observer observer) { + @SuppressWarnings("resource") MapNotificationObserver mn = new MapNotificationObserver( observer, Functions.justFunction(Observable.just(1)), 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 20a987dc00..a7391ca695 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 @@ -1215,6 +1215,7 @@ public boolean isDisposed() { } } + @SuppressWarnings("resource") @Test public void doubleOnX() { List errors = TestHelper.trackPluginErrors(); @@ -1231,6 +1232,7 @@ public void doubleOnX() { } } + @SuppressWarnings("resource") @Test public void doubleOnXCount() { List errors = TestHelper.trackPluginErrors(); @@ -1247,6 +1249,7 @@ public void doubleOnXCount() { } } + @SuppressWarnings("resource") @Test public void doubleOnXTime() { List errors = TestHelper.trackPluginErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableResourceWrapperTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableResourceWrapperTest.java index ca441d555e..36f7c472d1 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableResourceWrapperTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableResourceWrapperTest.java @@ -28,6 +28,7 @@ public class ObservableResourceWrapperTest extends RxJavaTest { @Test public void disposed() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") ObserverResourceWrapper orw = new ObserverResourceWrapper<>(to); Disposable d = Disposable.empty(); @@ -52,6 +53,7 @@ public void doubleOnSubscribe() { @Test public void onErrorDisposes() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") ObserverResourceWrapper orw = new ObserverResourceWrapper<>(to); Disposable d = Disposable.empty(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableSwitchTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableSwitchTest.java index 23069ea053..4dee50754d 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableSwitchTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableSwitchTest.java @@ -1425,6 +1425,7 @@ public void cancellationShouldTriggerInnerCancellationRace() throws Throwable { Observable createObservable(AtomicInteger inner) { return Observable.unsafeCreate(s -> { + @SuppressWarnings("resource") SerializedObserver it = new SerializedObserver<>(s); it.onSubscribe(Disposable.empty()); Schedulers.io().scheduleDirect(() -> { diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableThrottleLatestTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableThrottleLatestTest.java index ca60db9bfe..7baf15b379 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableThrottleLatestTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableThrottleLatestTest.java @@ -230,6 +230,7 @@ public void onDroppedBasicNoEmitLast() { TestScheduler sch = new TestScheduler(); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -273,6 +274,7 @@ public void onDroppedBasicNoEmitLastDropLast() { TestScheduler sch = new TestScheduler(); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -311,6 +313,7 @@ public void onDroppedBasicEmitLast() { TestScheduler sch = new TestScheduler(); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -456,6 +459,7 @@ public void onDroppedBasicNoEmitLastNoLastToDrop() { TestScheduler sch = new TestScheduler(); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -483,6 +487,7 @@ public void onDroppedErrorNoEmitLastNoLastToDrop() { TestScheduler sch = new TestScheduler(); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -547,6 +552,7 @@ public void onDroppedDisposeDrops() throws Throwable { Action whenDisposed = mock(Action.class); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); @@ -584,6 +590,7 @@ public void onDroppedDisposeNoDrops() throws Throwable { Action whenDisposed = mock(Action.class); + @SuppressWarnings("resource") TestObserver drops = new TestObserver<>(); drops.onSubscribe(Disposable.empty()); 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 d83e625066..71d79f799d 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 @@ -104,6 +104,7 @@ public void shouldTimeoutIfSecondOnNextNotWithinTimeout() { @Test public void shouldCompleteIfUnderlyingComletes() { Observer observer = TestHelper.mockObserver(); + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(observer); withTimeout.subscribe(observer); testScheduler.advanceTimeBy(2, TimeUnit.SECONDS); @@ -117,6 +118,7 @@ public void shouldCompleteIfUnderlyingComletes() { @Test public void shouldErrorIfUnderlyingErrors() { Observer observer = TestHelper.mockObserver(); + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(observer); withTimeout.subscribe(observer); testScheduler.advanceTimeBy(2, TimeUnit.SECONDS); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimerTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimerTest.java index 3a1d559c7c..acee0cd72c 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimerTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/observable/ObservableTimerTest.java @@ -350,6 +350,7 @@ public Long apply(Long v) throws Exception { public void cancelledAndRun() { TestObserver to = new TestObserver<>(); to.onSubscribe(Disposable.empty()); + @SuppressWarnings("resource") TimerObserver tm = new TimerObserver(to); tm.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTest.java new file mode 100644 index 0000000000..4fb59761db --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/streamable/StreamableTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.rxjava4.internal.operators.streamable; + +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Test; + +import io.reactivex.rxjava4.core.Streamable; +import io.reactivex.rxjava4.exceptions.TestException; +import io.reactivex.rxjava4.internal.subscriptions.*; +import io.reactivex.rxjava4.subscribers.TestSubscriber; +import io.reactivex.rxjava4.testsupport.TestHelper; + +public class StreamableTest { + + @Test + public void empty() throws Throwable { + TestHelper.withVirtual(exec -> { + + TestSubscriber ts = new TestSubscriber(); + ts.onSubscribe(EmptySubscription.INSTANCE); + + var comp = Streamable.empty().forEach(e -> { ts.onError(new TestException("Element produced? " + e)); }, exec); + + comp.stage().toCompletableFuture().thenAccept(_ -> ts.onComplete()).exceptionally(e -> { ts.onError(e); return null; }).join(); + + ts + .awaitDone(5, TimeUnit.SECONDS) + .assertResult(); + }); + } + + @Test + public void just() throws Throwable { + TestHelper.withVirtual(exec -> { + + TestSubscriber ts = new TestSubscriber(); + ts.onSubscribe(EmptySubscription.INSTANCE); + + var comp = Streamable.just(1).forEach(e -> { ts.onNext(e); }, exec); + + comp.stage().toCompletableFuture().thenAccept(_ -> ts.onComplete()).exceptionally(e -> { ts.onError(e); return null; }).join(); + + ts + .awaitDone(5, TimeUnit.SECONDS) + .assertResult(1); + }); + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/AbstractDirectTaskTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/AbstractDirectTaskTest.java index 267fe4fed3..1306474afd 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/AbstractDirectTaskTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/AbstractDirectTaskTest.java @@ -27,6 +27,7 @@ public class AbstractDirectTaskTest extends RxJavaTest { @Test public void cancelSetFuture() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -58,6 +59,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void cancelSetFutureCurrentThread() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -91,6 +93,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void setFutureCancel() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -119,6 +122,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void setFutureCancelSameThread() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -148,6 +152,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void finished() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -177,6 +182,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void finishedCancel() { + @SuppressWarnings("resource") AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -211,6 +217,7 @@ public boolean cancel(boolean mayInterruptIfRunning) { @Test public void disposeSetFutureRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final AbstractDirectTask task = new AbstractDirectTask(Functions.EMPTY_RUNNABLE, true) { private static final long serialVersionUID = 208585707945686116L; }; @@ -252,6 +259,7 @@ static class TestDirectTask extends AbstractDirectTask { @Test public void toStringStates() { + @SuppressWarnings("resource") TestDirectTask task = new TestDirectTask(); assertEquals("TestDirectTask[Waiting]", task.toString()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/BooleanRunnableTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/BooleanRunnableTest.java index f1c6191522..39cd2ec8ff 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/BooleanRunnableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/BooleanRunnableTest.java @@ -31,6 +31,7 @@ public class BooleanRunnableTest extends RxJavaTest { public void runnableThrows() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") BooleanRunnable task = new BooleanRunnable(() -> { throw new TestException(); }); diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ExecutorSchedulerDelayedRunnableTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ExecutorSchedulerDelayedRunnableTest.java index 76140fc3f6..1a86fe4867 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ExecutorSchedulerDelayedRunnableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ExecutorSchedulerDelayedRunnableTest.java @@ -29,6 +29,7 @@ public class ExecutorSchedulerDelayedRunnableTest extends RxJavaTest { @Test(expected = TestException.class) @SuppressUndeliverable public void delayedRunnableCrash() { + @SuppressWarnings("resource") DelayedRunnable dl = new DelayedRunnable(new Runnable() { @Override public void run() { @@ -41,6 +42,7 @@ public void run() { @Test public void dispose() { final AtomicInteger count = new AtomicInteger(); + @SuppressWarnings("resource") DelayedRunnable dl = new DelayedRunnable(new Runnable() { @Override public void run() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/InstantPeriodicTaskTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/InstantPeriodicTaskTest.java index e5fb325ae9..d299961888 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/InstantPeriodicTaskTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/InstantPeriodicTaskTest.java @@ -34,6 +34,7 @@ public void taskCrash() throws Exception { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -60,6 +61,7 @@ public void dispose() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -87,6 +89,7 @@ public void dispose2() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -117,6 +120,7 @@ public void dispose2CurrentThread() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -149,6 +153,7 @@ public void dispose3() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -178,6 +183,7 @@ public void disposeOnCurrentThread() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { + @SuppressWarnings("resource") InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -209,6 +215,7 @@ public void firstCancelRace() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) { + @SuppressWarnings("resource") final InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { @@ -246,6 +253,7 @@ public void restCancelRace() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(); try { for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) { + @SuppressWarnings("resource") final InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() { @Override public void run() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/InterruptibleRunnableTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/InterruptibleRunnableTest.java index fce7ee9e33..b8129ad6d8 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/InterruptibleRunnableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/InterruptibleRunnableTest.java @@ -31,6 +31,7 @@ public class InterruptibleRunnableTest extends RxJavaTest { public void runnableThrows() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") InterruptibleRunnable task = new InterruptibleRunnable(() -> { throw new TestException(); }, null); diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledDirectPeriodicTaskTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledDirectPeriodicTaskTest.java index 864e5ba565..b4dc03b6d0 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledDirectPeriodicTaskTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledDirectPeriodicTaskTest.java @@ -30,6 +30,7 @@ public class ScheduledDirectPeriodicTaskTest extends RxJavaTest { public void runnableThrows() { List errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") ScheduledDirectPeriodicTask task = new ScheduledDirectPeriodicTask(new Runnable() { @Override public void run() { diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledRunnableTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledRunnableTest.java index c180cfb7c3..2d1c2fc72d 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledRunnableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/ScheduledRunnableTest.java @@ -227,6 +227,7 @@ public void run() { @Test public void withoutParentDisposed() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.dispose(); run.call(); @@ -234,6 +235,7 @@ public void withoutParentDisposed() { @Test public void withParentDisposed() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, new CompositeDisposable()); run.dispose(); run.call(); @@ -241,6 +243,7 @@ public void withParentDisposed() { @Test public void withFutureDisposed() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.setFuture(new FutureTask(Functions.EMPTY_RUNNABLE, null)); run.dispose(); @@ -249,6 +252,7 @@ public void withFutureDisposed() { @Test public void withFutureDisposed2() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.dispose(); run.setFuture(new FutureTask(Functions.EMPTY_RUNNABLE, null)); @@ -257,6 +261,7 @@ public void withFutureDisposed2() { @Test public void withFutureDisposed3() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.dispose(); run.set(2, Thread.currentThread()); @@ -344,6 +349,7 @@ public void run() { @Test public void disposeAfterRun() { + @SuppressWarnings("resource") final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.run(); @@ -355,6 +361,7 @@ public void disposeAfterRun() { @Test public void syncDisposeIdempotent() { + @SuppressWarnings("resource") final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.set(ScheduledRunnable.THREAD_INDEX, Thread.currentThread()); @@ -368,6 +375,7 @@ public void syncDisposeIdempotent() { @Test public void asyncDisposeIdempotent() { + @SuppressWarnings("resource") final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); run.dispose(); @@ -380,6 +388,7 @@ public void asyncDisposeIdempotent() { @Test public void noParentIsDisposed() { + @SuppressWarnings("resource") ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, null); assertFalse(run.isDisposed()); run.run(); @@ -400,6 +409,7 @@ public void withParentIsDisposed() { assertFalse(set.remove(run)); } + @SuppressWarnings("resource") @Test public void toStringStates() { CompositeDisposable set = new CompositeDisposable(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerMultiWorkerSupportTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerMultiWorkerSupportTest.java index 5d6470cc6d..19cedb6343 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerMultiWorkerSupportTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerMultiWorkerSupportTest.java @@ -69,6 +69,7 @@ public void onWorker(int i, Worker w) { public void distinctThreads() throws Exception { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") final CompositeDisposable composite = new CompositeDisposable(); try { diff --git a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerWhenTest.java b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerWhenTest.java index a4a6bcc409..f080c26f8b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerWhenTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/schedulers/SchedulerWhenTest.java @@ -230,6 +230,7 @@ public void subscribedDisposable() { assertFalse(SchedulerWhen.SUBSCRIBED.isDisposed()); } + @SuppressWarnings("resource") @Test(expected = TestException.class) public void combineCrashInConstructor() { new SchedulerWhen(new Function>, Completable>() { @@ -241,6 +242,7 @@ public Completable apply(Flowable> v) }, Schedulers.single()); } + @SuppressWarnings("resource") @Test public void disposed() { SchedulerWhen sw = new SchedulerWhen(new Function>, Completable>() { @@ -261,6 +263,7 @@ public Completable apply(Flowable> v) @Test public void scheduledActiondisposedSetRace() { for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) { + @SuppressWarnings("resource") final ScheduledAction sa = new ScheduledAction() { private static final long serialVersionUID = -672980251643733156L; @@ -288,6 +291,7 @@ public void run() { } } + @SuppressWarnings("resource") @Test public void scheduledActionStates() { final AtomicInteger count = new AtomicInteger(); @@ -381,6 +385,7 @@ public void onError(Throwable e) { @Test public void queueWorkerDispose() { + @SuppressWarnings("resource") QueueWorker qw = new QueueWorker(PublishProcessor.create(), Schedulers.single().createWorker()); assertFalse(qw.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscribers/BoundedSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscribers/BoundedSubscriberTest.java index e31315c4cb..65835c4d3b 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscribers/BoundedSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscribers/BoundedSubscriberTest.java @@ -362,6 +362,7 @@ public void accept(Subscription s) throws Exception { @Test public void onErrorMissingShouldReportNoCustomOnError() { + @SuppressWarnings("resource") BoundedSubscriber subscriber = new BoundedSubscriber<>(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION, @@ -372,6 +373,7 @@ public void onErrorMissingShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") BoundedSubscriber subscriber = new BoundedSubscriber<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, @@ -382,6 +384,7 @@ public void customOnErrorShouldReportCustomOnError() { @Test public void cancel() { + @SuppressWarnings("resource") BoundedSubscriber subscriber = new BoundedSubscriber<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, @@ -397,6 +400,7 @@ public void cancel() { @Test public void dispose() { + @SuppressWarnings("resource") BoundedSubscriber subscriber = new BoundedSubscriber<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscribers/LambdaSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscribers/LambdaSubscriberTest.java index 4d536f0e95..735d338c15 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscribers/LambdaSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscribers/LambdaSubscriberTest.java @@ -355,6 +355,7 @@ public void accept(Subscription s) throws Exception { @Test public void onErrorMissingShouldReportNoCustomOnError() { + @SuppressWarnings("resource") LambdaSubscriber subscriber = new LambdaSubscriber<>(Functions.emptyConsumer(), Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION, @@ -365,6 +366,7 @@ public void onErrorMissingShouldReportNoCustomOnError() { @Test public void customOnErrorShouldReportCustomOnError() { + @SuppressWarnings("resource") LambdaSubscriber subscriber = new LambdaSubscriber<>(Functions.emptyConsumer(), Functions.emptyConsumer(), Functions.EMPTY_ACTION, diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/ArrayCompositeSubscriptionTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/ArrayCompositeSubscriptionTest.java index 2465436bd6..7570bdbc0e 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/ArrayCompositeSubscriptionTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/ArrayCompositeSubscriptionTest.java @@ -22,6 +22,7 @@ public class ArrayCompositeSubscriptionTest extends RxJavaTest { + @SuppressWarnings("resource") @Test public void set() { ArrayCompositeSubscription ac = new ArrayCompositeSubscription(1); @@ -57,6 +58,7 @@ public void set() { assertFalse(ac.setResource(0, null)); } + @SuppressWarnings("resource") @Test public void replace() { ArrayCompositeSubscription ac = new ArrayCompositeSubscription(1); @@ -92,6 +94,7 @@ public void replace() { ac.replaceResource(0, null); } + @SuppressWarnings("resource") @Test public void disposeRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { @@ -108,6 +111,7 @@ public void run() { } } + @SuppressWarnings("resource") @Test public void setReplaceRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/AsyncSubscriptionTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/AsyncSubscriptionTest.java index 7e6dc9df21..f6b23527a5 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscriptions/AsyncSubscriptionTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscriptions/AsyncSubscriptionTest.java @@ -24,6 +24,8 @@ import io.reactivex.rxjava4.disposables.Disposable; public class AsyncSubscriptionTest extends RxJavaTest { + + @SuppressWarnings("resource") @Test public void noResource() { AsyncSubscription as = new AsyncSubscription(); @@ -40,6 +42,7 @@ public void noResource() { verify(s).cancel(); } + @SuppressWarnings("resource") @Test public void requestBeforeSet() { AsyncSubscription as = new AsyncSubscription(); @@ -56,6 +59,7 @@ public void requestBeforeSet() { verify(s).cancel(); } + @SuppressWarnings("resource") @Test public void cancelBeforeSet() { AsyncSubscription as = new AsyncSubscription(); @@ -71,6 +75,7 @@ public void cancelBeforeSet() { verify(s).cancel(); } + @SuppressWarnings("resource") @Test public void singleSet() { AsyncSubscription as = new AsyncSubscription(); @@ -88,6 +93,7 @@ public void singleSet() { verify(s1).cancel(); } + @SuppressWarnings("resource") @Test public void initialResource() { Disposable r = mock(Disposable.class); @@ -98,6 +104,7 @@ public void initialResource() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void setResource() { AsyncSubscription as = new AsyncSubscription(); @@ -111,6 +118,7 @@ public void setResource() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void replaceResource() { AsyncSubscription as = new AsyncSubscription(); @@ -124,6 +132,7 @@ public void replaceResource() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void setResource2() { AsyncSubscription as = new AsyncSubscription(); @@ -142,6 +151,7 @@ public void setResource2() { verify(r2).dispose(); } + @SuppressWarnings("resource") @Test public void replaceResource2() { AsyncSubscription as = new AsyncSubscription(); @@ -160,6 +170,7 @@ public void replaceResource2() { verify(r2).dispose(); } + @SuppressWarnings("resource") @Test public void setResourceAfterCancel() { AsyncSubscription as = new AsyncSubscription(); @@ -173,6 +184,7 @@ public void setResourceAfterCancel() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void replaceResourceAfterCancel() { AsyncSubscription as = new AsyncSubscription(); @@ -185,6 +197,7 @@ public void replaceResourceAfterCancel() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void cancelOnce() { Disposable r = mock(Disposable.class); @@ -202,6 +215,7 @@ public void cancelOnce() { verify(r).dispose(); } + @SuppressWarnings("resource") @Test public void disposed() { AsyncSubscription as = new AsyncSubscription(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/util/EndConsumerHelperTest.java b/src/test/java/io/reactivex/rxjava4/internal/util/EndConsumerHelperTest.java index 073accaac8..7a27cd8d41 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/util/EndConsumerHelperTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/util/EndConsumerHelperTest.java @@ -125,6 +125,7 @@ public void checkDoubleDefaultSubscriberNonAnonymous() { @Test public void checkDoubleDisposableSubscriber() { + @SuppressWarnings("resource") Subscriber consumer = new DisposableSubscriber() { @Override public void onNext(Integer t) { @@ -160,6 +161,7 @@ public void onComplete() { @Test public void checkDoubleResourceSubscriber() { + @SuppressWarnings("resource") Subscriber consumer = new ResourceSubscriber() { @Override public void onNext(Integer t) { @@ -230,6 +232,7 @@ public void onComplete() { @Test public void checkDoubleDisposableObserver() { + @SuppressWarnings("resource") Observer consumer = new DisposableObserver() { @Override public void onNext(Integer t) { @@ -265,6 +268,7 @@ public void onComplete() { @Test public void checkDoubleResourceObserver() { + @SuppressWarnings("resource") Observer consumer = new ResourceObserver() { @Override public void onNext(Integer t) { @@ -300,6 +304,7 @@ public void onComplete() { @Test public void checkDoubleDisposableSingleObserver() { + @SuppressWarnings("resource") SingleObserver consumer = new DisposableSingleObserver() { @Override public void onSuccess(Integer t) { @@ -331,6 +336,7 @@ public void onError(Throwable t) { @Test public void checkDoubleResourceSingleObserver() { + @SuppressWarnings("resource") SingleObserver consumer = new ResourceSingleObserver() { @Override public void onSuccess(Integer t) { @@ -362,6 +368,7 @@ public void onError(Throwable t) { @Test public void checkDoubleDisposableMaybeObserver() { + @SuppressWarnings("resource") MaybeObserver consumer = new DisposableMaybeObserver() { @Override public void onSuccess(Integer t) { @@ -397,6 +404,7 @@ public void onComplete() { @Test public void checkDoubleResourceMaybeObserver() { + @SuppressWarnings("resource") MaybeObserver consumer = new ResourceMaybeObserver() { @Override public void onSuccess(Integer t) { @@ -432,6 +440,7 @@ public void onComplete() { @Test public void checkDoubleDisposableCompletableObserver() { + @SuppressWarnings("resource") CompletableObserver consumer = new DisposableCompletableObserver() { @Override public void onError(Throwable t) { @@ -463,6 +472,7 @@ public void onComplete() { @Test public void checkDoubleResourceCompletableObserver() { + @SuppressWarnings("resource") CompletableObserver consumer = new ResourceCompletableObserver() { @Override public void onError(Throwable t) { diff --git a/src/test/java/io/reactivex/rxjava4/internal/util/HalfSerializerObserverTest.java b/src/test/java/io/reactivex/rxjava4/internal/util/HalfSerializerObserverTest.java index 2eb8d1fd07..961977b9d9 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/util/HalfSerializerObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/util/HalfSerializerObserverTest.java @@ -36,6 +36,7 @@ public void reentrantOnNextOnNext() { final Observer[] a = { null }; + @SuppressWarnings("resource") final TestObserver to = new TestObserver(); Observer observer = new Observer() { @@ -80,6 +81,7 @@ public void reentrantOnNextOnError() { final Observer[] a = { null }; + @SuppressWarnings("resource") final TestObserver to = new TestObserver(); Observer observer = new Observer() { @@ -124,6 +126,7 @@ public void reentrantOnNextOnComplete() { final Observer[] a = { null }; + @SuppressWarnings("resource") final TestObserver to = new TestObserver(); Observer observer = new Observer() { @@ -169,6 +172,7 @@ public void reentrantErrorOnError() { final Observer[] a = { null }; + @SuppressWarnings("resource") final TestObserver to = new TestObserver(); Observer observer = new Observer() { diff --git a/src/test/java/io/reactivex/rxjava4/observers/DisposableCompletableObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/DisposableCompletableObserverTest.java index 3ffc762f6d..0f27376844 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/DisposableCompletableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/DisposableCompletableObserverTest.java @@ -77,6 +77,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestCompletable tc = new TestCompletable(); tc.onSubscribe(Disposable.empty()); @@ -97,6 +98,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestCompletable tc = new TestCompletable(); tc.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/DisposableMaybeObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/DisposableMaybeObserverTest.java index 8e7f88b669..667274a371 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/DisposableMaybeObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/DisposableMaybeObserverTest.java @@ -85,6 +85,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestMaybe tc = new TestMaybe<>(); tc.onSubscribe(Disposable.empty()); @@ -105,6 +106,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestMaybe tc = new TestMaybe<>(); tc.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/DisposableObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/DisposableObserverTest.java index 33e2de249d..67b56da786 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/DisposableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/DisposableObserverTest.java @@ -84,6 +84,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestDisposableObserver tc = new TestDisposableObserver<>(); tc.onSubscribe(Disposable.empty()); @@ -104,6 +105,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestDisposableObserver tc = new TestDisposableObserver<>(); assertFalse(tc.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/observers/DisposableSingleObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/DisposableSingleObserverTest.java index 99de9a005c..674419e524 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/DisposableSingleObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/DisposableSingleObserverTest.java @@ -77,6 +77,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestSingle tc = new TestSingle<>(); tc.onSubscribe(Disposable.empty()); @@ -97,6 +98,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestSingle tc = new TestSingle<>(); tc.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/ResourceCompletableObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/ResourceCompletableObserverTest.java index f5d5e77d10..68783afcb9 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/ResourceCompletableObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/ResourceCompletableObserverTest.java @@ -58,12 +58,14 @@ public void onError(Throwable e) { @Test(expected = NullPointerException.class) public void nullResource() { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); rco.add(null); } @Test public void addResources() { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); assertFalse(rco.isDisposed()); @@ -89,6 +91,7 @@ public void addResources() { @Test public void onCompleteCleansUp() { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); assertFalse(rco.isDisposed()); @@ -108,6 +111,7 @@ public void onCompleteCleansUp() { @Test public void onErrorCleansUp() { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); assertFalse(rco.isDisposed()); @@ -165,6 +169,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); rco.onSubscribe(Disposable.empty()); @@ -185,6 +190,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestResourceCompletableObserver rco = new TestResourceCompletableObserver(); rco.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/ResourceMaybeObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/ResourceMaybeObserverTest.java index 8e3e88a7aa..f539ffd738 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/ResourceMaybeObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/ResourceMaybeObserverTest.java @@ -67,12 +67,14 @@ public void onError(Throwable e) { @Test(expected = NullPointerException.class) public void nullResource() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); rmo.add(null); } @Test public void addResources() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); assertFalse(rmo.isDisposed()); @@ -98,6 +100,7 @@ public void addResources() { @Test public void onCompleteCleansUp() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); assertFalse(rmo.isDisposed()); @@ -117,6 +120,7 @@ public void onCompleteCleansUp() { @Test public void onSuccessCleansUp() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); assertFalse(rmo.isDisposed()); @@ -136,6 +140,7 @@ public void onSuccessCleansUp() { @Test public void onErrorCleansUp() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); assertFalse(rmo.isDisposed()); @@ -215,6 +220,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); rmo.onSubscribe(Disposable.empty()); @@ -235,6 +241,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestResourceMaybeObserver rmo = new TestResourceMaybeObserver<>(); rmo.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/ResourceObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/ResourceObserverTest.java index 668d035789..5b01094efe 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/ResourceObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/ResourceObserverTest.java @@ -67,12 +67,14 @@ public void onComplete() { @Test(expected = NullPointerException.class) public void nullResource() { + @SuppressWarnings("resource") TestResourceObserver ro = new TestResourceObserver<>(); ro.add(null); } @Test public void addResources() { + @SuppressWarnings("resource") TestResourceObserver ro = new TestResourceObserver<>(); assertFalse(ro.isDisposed()); @@ -98,6 +100,7 @@ public void addResources() { @Test public void onCompleteCleansUp() { + @SuppressWarnings("resource") TestResourceObserver ro = new TestResourceObserver<>(); assertFalse(ro.isDisposed()); @@ -117,6 +120,7 @@ public void onCompleteCleansUp() { @Test public void onErrorCleansUp() { + @SuppressWarnings("resource") TestResourceObserver ro = new TestResourceObserver<>(); assertFalse(ro.isDisposed()); @@ -176,6 +180,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestResourceObserver tc = new TestResourceObserver<>(); tc.onSubscribe(Disposable.empty()); @@ -196,6 +201,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestResourceObserver tc = new TestResourceObserver<>(); tc.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/ResourceSingleObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/ResourceSingleObserverTest.java index ff4bfc0969..925087dbb1 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/ResourceSingleObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/ResourceSingleObserverTest.java @@ -58,12 +58,14 @@ public void onError(Throwable e) { @Test(expected = NullPointerException.class) public void nullResource() { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); rso.add(null); } @Test public void addResources() { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); assertFalse(rso.isDisposed()); @@ -89,6 +91,7 @@ public void addResources() { @Test public void onSuccessCleansUp() { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); assertFalse(rso.isDisposed()); @@ -108,6 +111,7 @@ public void onSuccessCleansUp() { @Test public void onErrorCleansUp() { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); assertFalse(rso.isDisposed()); @@ -167,6 +171,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); rso.onSubscribe(Disposable.empty()); @@ -187,6 +192,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestResourceSingleObserver rso = new TestResourceSingleObserver<>(); rso.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/SafeObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/SafeObserverTest.java index cf0abdfcd1..fe22a461ee 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/SafeObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/SafeObserverTest.java @@ -45,6 +45,7 @@ public void onNextFailure() { public void onNextFailureSafe() { AtomicReference onError = new AtomicReference<>(); try { + @SuppressWarnings("resource") SafeObserver safeObserver = new SafeObserver<>(OBSERVER_ONNEXT_FAIL(onError)); safeObserver.onSubscribe(Disposable.empty()); safeObserver.onNext("one"); @@ -198,6 +199,7 @@ public void onError(Throwable e) { public void onComplete() { } }; + @SuppressWarnings("resource") SafeObserver observer = new SafeObserver<>(actual); assertSame(actual, observer.downstream); @@ -207,6 +209,7 @@ public void onComplete() { public void dispose() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); Disposable d = Disposable.empty(); @@ -225,6 +228,7 @@ public void dispose() { public void onNextAfterComplete() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); Disposable d = Disposable.empty(); @@ -246,6 +250,7 @@ public void onNextAfterComplete() { public void onNextNull() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); Disposable d = Disposable.empty(); @@ -261,6 +266,7 @@ public void onNextNull() { public void onNextWithoutOnSubscribe() { TestObserverEx to = new TestObserverEx<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); so.onNext(1); @@ -272,6 +278,7 @@ public void onNextWithoutOnSubscribe() { public void onErrorWithoutOnSubscribe() { TestObserverEx to = new TestObserverEx<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); so.onError(new TestException()); @@ -286,6 +293,7 @@ public void onErrorWithoutOnSubscribe() { public void onCompleteWithoutOnSubscribe() { TestObserverEx to = new TestObserverEx<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); so.onComplete(); @@ -297,6 +305,7 @@ public void onCompleteWithoutOnSubscribe() { public void onNextNormal() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") SafeObserver so = new SafeObserver<>(to); Disposable d = Disposable.empty(); @@ -481,6 +490,7 @@ public void onNextOnSubscribeCrash() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(true, 1, false, false, false); SafeObserver so = cd.toSafe(); @@ -512,6 +522,7 @@ public void noSubscribeOnErrorCrashes() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(false, 1, true, false, false); SafeObserver so = cd.toSafe(); @@ -542,6 +553,7 @@ public void onErrorNoSubscribeCrash() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(true, 1, false, false, false); SafeObserver so = cd.toSafe(); @@ -561,6 +573,7 @@ public void onErrorNoSubscribeOnErrorCrash() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(false, 1, true, false, false); SafeObserver so = cd.toSafe(); @@ -599,6 +612,7 @@ public void onCompleteteNoSubscribeCrash() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(true, 1, false, true, false); SafeObserver so = cd.toSafe(); @@ -618,6 +632,7 @@ public void onCompleteteNoSubscribeOnErrorCrash() { List list = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") CrashDummy cd = new CrashDummy(false, 1, true, true, false); SafeObserver so = cd.toSafe(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/SerializedObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/SerializedObserverTest.java index 0503948e82..8b42860418 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/SerializedObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/SerializedObserverTest.java @@ -900,6 +900,7 @@ public void onNext(Integer v) { public void dispose() { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); @@ -920,6 +921,7 @@ public void onCompleteRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); @@ -946,6 +948,7 @@ public void onNextOnCompleteRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); @@ -982,6 +985,7 @@ public void onNextOnErrorRace() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); @@ -1020,6 +1024,7 @@ public void onNextOnErrorRaceDelayError() { for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to, true); Disposable d = Disposable.empty(); @@ -1061,6 +1066,7 @@ public void startOnce() { try { TestObserver to = new TestObserver<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); so.onSubscribe(Disposable.empty()); @@ -1085,6 +1091,7 @@ public void onCompleteOnErrorRace() { try { TestObserverEx to = new TestObserverEx<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); @@ -1132,6 +1139,7 @@ public void nullOnNext() { TestObserverEx to = new TestObserverEx<>(); + @SuppressWarnings("resource") final SerializedObserver so = new SerializedObserver<>(to); Disposable d = Disposable.empty(); diff --git a/src/test/java/io/reactivex/rxjava4/observers/TestObserverTest.java b/src/test/java/io/reactivex/rxjava4/observers/TestObserverTest.java index 26ef1802db..25e95079fc 100644 --- a/src/test/java/io/reactivex/rxjava4/observers/TestObserverTest.java +++ b/src/test/java/io/reactivex/rxjava4/observers/TestObserverTest.java @@ -646,6 +646,7 @@ public void assertValueSequence() { @Test public void assertEmpty() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); try { @@ -671,6 +672,7 @@ public void assertEmpty() { @Test public void awaitDoneTimed() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); Thread.currentThread().interrupt(); @@ -684,6 +686,7 @@ public void awaitDoneTimed() { @Test public void assertErrorMultiple() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); TestException e = new TestException(); @@ -712,6 +715,7 @@ public void assertErrorMultiple() { @Test public void errorInPredicate() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); to.onError(new RuntimeException()); try { @@ -730,6 +734,7 @@ public boolean test(Throwable throwable) throws Exception { @Test public void assertComplete() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); to.onSubscribe(Disposable.empty()); @@ -757,6 +762,7 @@ public void assertComplete() { @Test public void completeWithoutOnSubscribe() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(); to.onComplete(); @@ -766,6 +772,7 @@ public void completeWithoutOnSubscribe() { @Test public void completeDelegateThrows() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(new Observer() { @Override @@ -802,6 +809,7 @@ public void onComplete() { @Test public void errorDelegateThrows() { + @SuppressWarnings("resource") TestObserver to = new TestObserver<>(new Observer() { @Override diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/AbstractSchedulerTests.java b/src/test/java/io/reactivex/rxjava4/schedulers/AbstractSchedulerTests.java index cd787efa9a..34666e9cad 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/AbstractSchedulerTests.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/AbstractSchedulerTests.java @@ -575,6 +575,7 @@ public void schedulePeriodicallyDirectZeroPeriod() throws Exception { for (int initial = 0; initial < 2; initial++) { final CountDownLatch cdl = new CountDownLatch(1); + @SuppressWarnings("resource") final SequentialDisposable sd = new SequentialDisposable(); try { @@ -608,6 +609,7 @@ public void schedulePeriodicallyZeroPeriod() throws Exception { for (int initial = 0; initial < 2; initial++) { final CountDownLatch cdl = new CountDownLatch(1); + @SuppressWarnings("resource") final SequentialDisposable sd = new SequentialDisposable(); Scheduler.Worker w = s.createWorker(); diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/ExecutorSchedulerTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/ExecutorSchedulerTest.java index b5b621ebc3..3d87a3f7af 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/ExecutorSchedulerTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/ExecutorSchedulerTest.java @@ -516,6 +516,7 @@ public void interruptibleRunnableRunDisposeRace() { try { Scheduler s = Schedulers.from(r -> exec.execute(r), true); for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + @SuppressWarnings("resource") SequentialDisposable sd = new SequentialDisposable(); TestHelper.race( diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java index f25c37c5ea..36452016da 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerLifecycleTest.java @@ -74,6 +74,7 @@ public void run() { } }; + @SuppressWarnings("resource") CompositeDisposable cd = new CompositeDisposable(); try { diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java index 582d3f6a47..7ff340ae22 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/SchedulerTest.java @@ -135,6 +135,7 @@ public void disposeSelfPeriodicDirect() { TestScheduler scheduler = new TestScheduler(); + @SuppressWarnings("resource") final SequentialDisposable sd = new SequentialDisposable(); Disposable d = scheduler.schedulePeriodicallyDirect(new Runnable() { @@ -165,6 +166,7 @@ public void disposeSelfPeriodic() { Worker worker = scheduler.createWorker(); try { + @SuppressWarnings("resource") final SequentialDisposable sd = new SequentialDisposable(); Disposable d = worker.schedulePeriodically(new Runnable() { diff --git a/src/test/java/io/reactivex/rxjava4/schedulers/TrampolineSchedulerTest.java b/src/test/java/io/reactivex/rxjava4/schedulers/TrampolineSchedulerTest.java index 6e19926b39..759a0fe640 100644 --- a/src/test/java/io/reactivex/rxjava4/schedulers/TrampolineSchedulerTest.java +++ b/src/test/java/io/reactivex/rxjava4/schedulers/TrampolineSchedulerTest.java @@ -64,6 +64,7 @@ public void accept(String t) { @Test public void nestedTrampolineWithUnsubscribe() { final ArrayList workDone = new ArrayList<>(); + @SuppressWarnings("resource") final CompositeDisposable workers = new CompositeDisposable(); Worker worker = Schedulers.trampoline().createWorker(); try { diff --git a/src/test/java/io/reactivex/rxjava4/single/SingleTest.java b/src/test/java/io/reactivex/rxjava4/single/SingleTest.java index 5991bab96d..1172d4eca6 100644 --- a/src/test/java/io/reactivex/rxjava4/single/SingleTest.java +++ b/src/test/java/io/reactivex/rxjava4/single/SingleTest.java @@ -301,6 +301,7 @@ public void run() { */ @Test public void unsubscribe2() throws InterruptedException { + @SuppressWarnings("resource") final SerialDisposable sd = new SerialDisposable(); SingleObserver ts = new SingleObserver() { diff --git a/src/test/java/io/reactivex/rxjava4/subscribers/DisposableSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/subscribers/DisposableSubscriberTest.java index 430983d89a..b88960586b 100644 --- a/src/test/java/io/reactivex/rxjava4/subscribers/DisposableSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/subscribers/DisposableSubscriberTest.java @@ -83,6 +83,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestDisposableSubscriber tc = new TestDisposableSubscriber<>(); tc.onSubscribe(new BooleanSubscription()); @@ -103,6 +104,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestDisposableSubscriber tc = new TestDisposableSubscriber<>(); assertFalse(tc.isDisposed()); diff --git a/src/test/java/io/reactivex/rxjava4/subscribers/ResourceSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/subscribers/ResourceSubscriberTest.java index 4f6244ca94..b2a0f319ab 100644 --- a/src/test/java/io/reactivex/rxjava4/subscribers/ResourceSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/subscribers/ResourceSubscriberTest.java @@ -71,12 +71,14 @@ void requestMore(long n) { @Test(expected = NullPointerException.class) public void nullResource() { + @SuppressWarnings("resource") TestResourceSubscriber ro = new TestResourceSubscriber<>(); ro.add(null); } @Test public void addResources() { + @SuppressWarnings("resource") TestResourceSubscriber ro = new TestResourceSubscriber<>(); assertFalse(ro.isDisposed()); @@ -102,6 +104,7 @@ public void addResources() { @Test public void onCompleteCleansUp() { + @SuppressWarnings("resource") TestResourceSubscriber ro = new TestResourceSubscriber<>(); assertFalse(ro.isDisposed()); @@ -121,6 +124,7 @@ public void onCompleteCleansUp() { @Test public void onErrorCleansUp() { + @SuppressWarnings("resource") TestResourceSubscriber ro = new TestResourceSubscriber<>(); assertFalse(ro.isDisposed()); @@ -161,6 +165,7 @@ public void startOnce() { List error = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") TestResourceSubscriber tc = new TestResourceSubscriber<>(); tc.onSubscribe(new BooleanSubscription()); @@ -181,6 +186,7 @@ public void startOnce() { @Test public void dispose() { + @SuppressWarnings("resource") TestResourceSubscriber tc = new TestResourceSubscriber<>(); tc.dispose(); diff --git a/src/test/java/io/reactivex/rxjava4/testsupport/TestHelper.java b/src/test/java/io/reactivex/rxjava4/testsupport/TestHelper.java index 4ac3cf74d2..bdd931eda2 100644 --- a/src/test/java/io/reactivex/rxjava4/testsupport/TestHelper.java +++ b/src/test/java/io/reactivex/rxjava4/testsupport/TestHelper.java @@ -3557,6 +3557,7 @@ public static void checkUndeliverableUponCancel(FlowableConverter errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") final SerialDisposable disposable = new SerialDisposable(); T result = Flowable.just(1) @@ -3625,6 +3626,7 @@ public static void checkUndeliverableUponCancel(ObservableConverter errors = TestHelper.trackPluginErrors(); try { + @SuppressWarnings("resource") final SerialDisposable disposable = new SerialDisposable(); T result = Observable.just(1) diff --git a/src/test/java/io/reactivex/rxjava4/testsupport/TestObserverExTest.java b/src/test/java/io/reactivex/rxjava4/testsupport/TestObserverExTest.java index 2fdb11fab8..d1e6076d12 100644 --- a/src/test/java/io/reactivex/rxjava4/testsupport/TestObserverExTest.java +++ b/src/test/java/io/reactivex/rxjava4/testsupport/TestObserverExTest.java @@ -184,6 +184,7 @@ public void errorSwallowed() { @Test public void nullExpected() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onNext(1); @@ -198,6 +199,7 @@ public void nullExpected() { @Test public void nullActual() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onNext(null); @@ -212,6 +214,7 @@ public void nullActual() { @Test public void terminalErrorOnce() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onError(new TestException()); to.onError(new TestException()); @@ -227,6 +230,7 @@ public void terminalErrorOnce() { @Test public void terminalCompletedOnce() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onComplete(); to.onComplete(); @@ -242,6 +246,7 @@ public void terminalCompletedOnce() { @Test public void terminalOneKind() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onError(new TestException()); to.onComplete(); @@ -259,6 +264,7 @@ public void terminalOneKind() { public void createDelegate() { TestObserverEx to1 = new TestObserverEx<>(); + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(to1); to.assertNotSubscribed(); @@ -316,6 +322,7 @@ public void createDelegate() { @Test public void assertError() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); try { @@ -441,6 +448,7 @@ public void valueAndClass() { @Test public void assertFailure() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -462,6 +470,7 @@ public void assertFailure() { to.assertFailureAndMessage(TestException.class, "Forced failure", 1); } + @SuppressWarnings("resource") @Test public void assertFuseable() { TestObserverEx to = new TestObserverEx<>(); @@ -511,6 +520,7 @@ public void assertFuseable() { @Test public void assertTerminated() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.assertNotTerminated(); @@ -527,6 +537,7 @@ public void assertTerminated() { @Test public void assertResult() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -564,6 +575,7 @@ public void assertResult() { @Test public void await() throws Exception { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -586,6 +598,7 @@ public void await() throws Exception { to.assertNoErrors().assertComplete(); + @SuppressWarnings("resource") final TestObserverEx to1 = new TestObserverEx<>(); to1.onSubscribe(Disposable.empty()); @@ -602,6 +615,7 @@ public void run() { @Test public void errors() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -617,6 +631,7 @@ public void errors() { @Test public void onNext() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -648,6 +663,7 @@ public void fusionModeToString() { @Test public void multipleTerminals() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -691,6 +707,7 @@ public void multipleTerminals() { @Test public void assertValue() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -723,6 +740,7 @@ public void assertValue() { } } + @SuppressWarnings("resource") @Test public void onNextMisbehave() { TestObserverEx to = new TestObserverEx<>(); @@ -740,6 +758,7 @@ public void onNextMisbehave() { to.assertFailure(NullPointerException.class, (Integer)null); } + @SuppressWarnings("resource") @Test public void assertTerminated2() { TestObserverEx to = new TestObserverEx<>(); @@ -783,6 +802,7 @@ public void assertTerminated2() { } } + @SuppressWarnings("resource") @Test public void onSubscribe() { TestObserverEx to = new TestObserverEx<>(); @@ -816,6 +836,7 @@ public void onSubscribe() { @Test public void assertValueSequence() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -849,6 +870,7 @@ public void assertValueSequence() { @Test public void assertEmpty() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); try { @@ -874,6 +896,7 @@ public void assertEmpty() { @Test public void awaitDoneTimed() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); Thread.currentThread().interrupt(); @@ -887,6 +910,7 @@ public void awaitDoneTimed() { @Test public void assertNotSubscribed() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.assertNotSubscribed(); @@ -903,6 +927,7 @@ public void assertNotSubscribed() { @Test public void assertErrorMultiple() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); TestException e = new TestException(); @@ -937,6 +962,7 @@ public void assertErrorMultiple() { @Test public void errorInPredicate() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onError(new RuntimeException()); try { @@ -955,6 +981,7 @@ public boolean test(Throwable throwable) throws Exception { @Test public void assertComplete() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -982,6 +1009,7 @@ public void assertComplete() { @Test public void completeWithoutOnSubscribe() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onComplete(); @@ -991,6 +1019,7 @@ public void completeWithoutOnSubscribe() { @Test public void completeDelegateThrows() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(new Observer() { @Override @@ -1027,6 +1056,7 @@ public void onComplete() { @Test public void errorDelegateThrows() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(new Observer() { @Override @@ -1312,6 +1342,7 @@ public void withTag() { @Test public void assertValuesOnly() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); to.assertValuesOnly(); @@ -1325,6 +1356,7 @@ public void assertValuesOnly() { @Test public void assertValuesOnlyThrowsOnUnexpectedValue() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); to.assertValuesOnly(); @@ -1344,6 +1376,7 @@ public void assertValuesOnlyThrowsOnUnexpectedValue() { @Test public void assertValuesOnlyThrowsWhenCompleted() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty()); @@ -1359,6 +1392,7 @@ public void assertValuesOnlyThrowsWhenCompleted() { @Test public void assertValuesOnlyThrowsWhenErrored() { + @SuppressWarnings("resource") TestObserverEx to = new TestObserverEx<>(); to.onSubscribe(Disposable.empty());