From 58d2df195c38db658de473704d502d5b3cf04dae Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 22:38:41 +0800 Subject: [PATCH 1/2] 4.x: Isolate Maybe using race tests --- .../maybe/MaybeUsingIsolatedTest.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingIsolatedTest.java diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingIsolatedTest.java new file mode 100644 index 0000000000..bb057ffb00 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingIsolatedTest.java @@ -0,0 +1,87 @@ +/* + * 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.maybe; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.exceptions.TestException; +import io.reactivex.rxjava4.observers.TestObserver; +import io.reactivex.rxjava4.subjects.PublishSubject; +import io.reactivex.rxjava4.testsupport.*; + +@Isolated +public class MaybeUsingIsolatedTest extends RxJavaTest { + + @Test + public void successDisposeRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + + final PublishSubject ps = PublishSubject.create(); + + final TestObserver to = Maybe.using(() -> 1, _ -> ps.lastElement(), _ -> { + }, true) + .test(); + + ps.onNext(1); + + Runnable r1 = to::dispose; + + Runnable r2 = ps::onComplete; + + TestHelper.race(r1, r2); + } + } + + @Test + @SuppressUndeliverable + public void errorDisposeRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + + final PublishSubject ps = PublishSubject.create(); + + final TestObserver to = Maybe.using(() -> 1, _ -> ps.firstElement(), _ -> { + }, true) + .test(); + + final TestException ex = new TestException(); + + Runnable r1 = to::dispose; + + Runnable r2 = () -> ps.onError(ex); + + TestHelper.race(r1, r2); + } + } + + @Test + public void emptyDisposeRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + + final PublishSubject ps = PublishSubject.create(); + + final TestObserver to = Maybe.using(() -> 1, _ -> ps.firstElement(), _ -> { + + }, true) + .test(); + + Runnable r1 = to::dispose; + + Runnable r2 = ps::onComplete; + + TestHelper.race(r1, r2); + } + } +} From a693f68c9ae4127903007fe9c37768fbc1c0755d Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 22:38:43 +0800 Subject: [PATCH 2/2] 4.x: Isolate Maybe using race tests --- .../operators/maybe/MaybeUsingTest.java | 60 ------------------- 1 file changed, 60 deletions(-) diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingTest.java index 7510d87013..18bbebd6da 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUsingTest.java @@ -234,66 +234,6 @@ public void doubleOnSubscribe() { } } - @Test - public void successDisposeRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - - final PublishSubject ps = PublishSubject.create(); - - final TestObserver to = Maybe.using(() -> 1, _ -> ps.lastElement(), _ -> { - }, true) - .test(); - - ps.onNext(1); - - Runnable r1 = to::dispose; - - Runnable r2 = ps::onComplete; - - TestHelper.race(r1, r2); - } - } - - @Test - @SuppressUndeliverable - public void errorDisposeRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - - final PublishSubject ps = PublishSubject.create(); - - final TestObserver to = Maybe.using(() -> 1, _ -> ps.firstElement(), _ -> { - }, true) - .test(); - - final TestException ex = new TestException(); - - Runnable r1 = to::dispose; - - Runnable r2 = () -> ps.onError(ex); - - TestHelper.race(r1, r2); - } - } - - @Test - public void emptyDisposeRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - - final PublishSubject ps = PublishSubject.create(); - - final TestObserver to = Maybe.using(() -> 1, _ -> ps.firstElement(), _ -> { - - }, true) - .test(); - - Runnable r1 = to::dispose; - - Runnable r2 = ps::onComplete; - - TestHelper.race(r1, r2); - } - } - @Test public void eagerDisposeResourceThenDisposeUpstream() { final StringBuilder sb = new StringBuilder();