From ec5a0e7828c76f42d45b63cd3be1171a0a3c2a4a Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 20:56:19 +0800 Subject: [PATCH 1/4] 4.x: Isolate Single cache and unsubscribeOn race tests --- .../single/SingleCacheIsolatedTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheIsolatedTest.java diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheIsolatedTest.java new file mode 100644 index 0000000000..ca29838691 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheIsolatedTest.java @@ -0,0 +1,43 @@ +/* + * 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.single; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.observers.TestObserver; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class SingleCacheIsolatedTest extends RxJavaTest { + + @Test + public void addRemoveRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + PublishProcessor pp = PublishProcessor.create(); + + final Single cached = pp.single(-99).cache(); + + final TestObserver to1 = cached.test(); + + Runnable r1 = to1::dispose; + + Runnable r2 = cached::test; + + TestHelper.race(r1, r2); + } + } +} From 2e22bdb6df02ff7ae72b50fcb5fcdf3e00d5e741 Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 20:56:22 +0800 Subject: [PATCH 2/4] 4.x: Isolate Single cache and unsubscribeOn race tests --- .../SingleUnsubscribeOnIsolatedTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnIsolatedTest.java diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnIsolatedTest.java new file mode 100644 index 0000000000..cf540a420a --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnIsolatedTest.java @@ -0,0 +1,57 @@ +/* + * 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.single; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.disposables.Disposable; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.schedulers.Schedulers; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class SingleUnsubscribeOnIsolatedTest extends RxJavaTest { + + @Test + public void disposeRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + PublishProcessor pp = PublishProcessor.create(); + + final Disposable[] ds = { null }; + pp.single(-99).unsubscribeOn(Schedulers.computation()) + .subscribe(new SingleObserver<>() /* NFI */ { + @Override + public void onSubscribe(Disposable d) { + ds[0] = d; + } + + @Override + public void onSuccess(Integer value) { + + } + + @Override + public void onError(Throwable e) { + + } + }); + + Runnable r = () -> ds[0].dispose(); + + TestHelper.race(r, r); + } + } +} From 29e8ca9ddba21444ddacbc4b0371f66078018796 Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 20:56:24 +0800 Subject: [PATCH 3/4] 4.x: Isolate Single cache and unsubscribeOn race tests --- .../operators/single/SingleCacheTest.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheTest.java index 2fe358742b..f71428c58e 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleCacheTest.java @@ -19,7 +19,6 @@ import io.reactivex.rxjava4.disposables.Disposable; import io.reactivex.rxjava4.observers.TestObserver; import io.reactivex.rxjava4.processors.PublishProcessor; -import io.reactivex.rxjava4.testsupport.TestHelper; public class SingleCacheTest extends RxJavaTest { @@ -39,23 +38,6 @@ public void cancelImmediately() { cached.test().assertResult(1); } - @Test - public void addRemoveRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - PublishProcessor pp = PublishProcessor.create(); - - final Single cached = pp.single(-99).cache(); - - final TestObserver to1 = cached.test(); - - Runnable r1 = to1::dispose; - - Runnable r2 = cached::test; - - TestHelper.race(r1, r2); - } - } - @Test public void doubleDispose() { PublishProcessor pp = PublishProcessor.create(); From 57d1106228b933af035045bd72d01c1f6385bcc1 Mon Sep 17 00:00:00 2001 From: jimi-21 Date: Mon, 16 Nov 2026 20:56:26 +0800 Subject: [PATCH 4/4] 4.x: Isolate Single cache and unsubscribeOn race tests --- .../single/SingleUnsubscribeOnTest.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnTest.java index 37683e9e21..d13bafd189 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/single/SingleUnsubscribeOnTest.java @@ -85,33 +85,4 @@ public void doubleOnSubscribe() { TestHelper.checkDoubleOnSubscribeSingle(v -> v.unsubscribeOn(Schedulers.single())); } - @Test - public void disposeRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - PublishProcessor pp = PublishProcessor.create(); - - final Disposable[] ds = { null }; - pp.single(-99).unsubscribeOn(Schedulers.computation()) - .subscribe(new SingleObserver<>() /* NFI */ { - @Override - public void onSubscribe(Disposable d) { - ds[0] = d; - } - - @Override - public void onSuccess(Integer value) { - - } - - @Override - public void onError(Throwable e) { - - } - }); - - Runnable r = () -> ds[0].dispose(); - - TestHelper.race(r, r); - } - } }