File tree 4 files changed +69
-3
lines changed
main/java/io/reactivex/rxjava3/internal/operators
test/java/io/reactivex/rxjava3/internal/operators
4 files changed +69
-3
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ public final void cancel() {
154
154
upstream .cancel ();
155
155
worker .dispose ();
156
156
157
- if (getAndIncrement () == 0 ) {
157
+ if (! outputFused && getAndIncrement () == 0 ) {
158
158
queue .clear ();
159
159
}
160
160
}
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public void dispose() {
145
145
disposed = true ;
146
146
upstream .dispose ();
147
147
worker .dispose ();
148
- if (getAndIncrement () == 0 ) {
148
+ if (! outputFused && getAndIncrement () == 0 ) {
149
149
queue .clear ();
150
150
}
151
151
}
Original file line number Diff line number Diff line change 35
35
import io .reactivex .rxjava3 .internal .operators .flowable .FlowableObserveOn .BaseObserveOnSubscriber ;
36
36
import io .reactivex .rxjava3 .internal .schedulers .ImmediateThinScheduler ;
37
37
import io .reactivex .rxjava3 .internal .subscriptions .BooleanSubscription ;
38
+ import io .reactivex .rxjava3 .observers .TestObserver ;
38
39
import io .reactivex .rxjava3 .plugins .RxJavaPlugins ;
39
40
import io .reactivex .rxjava3 .processors .*;
40
41
import io .reactivex .rxjava3 .schedulers .*;
@@ -1938,4 +1939,37 @@ public void workerNotDisposedPrematurelyNormalInAsyncOutConditional() {
1938
1939
1939
1940
assertEquals (1 , s .disposedCount .get ());
1940
1941
}
1942
+
1943
+ @ Test
1944
+ public void fusedNoConcurrentCleanDueToCancel () {
1945
+ for (int j = 0 ; j < TestHelper .RACE_LONG_LOOPS ; j ++) {
1946
+ List <Throwable > errors = TestHelper .trackPluginErrors ();
1947
+ try {
1948
+ final UnicastProcessor <Integer > up = UnicastProcessor .create ();
1949
+
1950
+ TestObserver <Integer > to = up .hide ()
1951
+ .observeOn (Schedulers .io ())
1952
+ .observeOn (Schedulers .single ())
1953
+ .unsubscribeOn (Schedulers .computation ())
1954
+ .firstOrError ()
1955
+ .test ();
1956
+
1957
+ for (int i = 0 ; up .hasSubscribers () && i < 10000 ; i ++) {
1958
+ up .onNext (i );
1959
+ }
1960
+
1961
+ to
1962
+ .awaitDone (5 , TimeUnit .SECONDS )
1963
+ ;
1964
+
1965
+ if (!errors .isEmpty ()) {
1966
+ throw new CompositeException (errors );
1967
+ }
1968
+
1969
+ to .assertResult (0 );
1970
+ } finally {
1971
+ RxJavaPlugins .reset ();
1972
+ }
1973
+ }
1974
+ }
1941
1975
}
Original file line number Diff line number Diff line change 29
29
import io .reactivex .rxjava3 .core .Observable ;
30
30
import io .reactivex .rxjava3 .core .Observer ;
31
31
import io .reactivex .rxjava3 .disposables .*;
32
- import io .reactivex .rxjava3 .exceptions .TestException ;
32
+ import io .reactivex .rxjava3 .exceptions .* ;
33
33
import io .reactivex .rxjava3 .functions .*;
34
34
import io .reactivex .rxjava3 .internal .fuseable .*;
35
35
import io .reactivex .rxjava3 .internal .operators .flowable .FlowableObserveOnTest .DisposeTrackingScheduler ;
@@ -815,4 +815,36 @@ public void workerNotDisposedPrematurelyNormalInAsyncOut() {
815
815
assertEquals (1 , s .disposedCount .get ());
816
816
}
817
817
818
+ @ Test
819
+ public void fusedNoConcurrentCleanDueToCancel () {
820
+ for (int j = 0 ; j < TestHelper .RACE_LONG_LOOPS ; j ++) {
821
+ List <Throwable > errors = TestHelper .trackPluginErrors ();
822
+ try {
823
+ final UnicastSubject <Integer > us = UnicastSubject .create ();
824
+
825
+ TestObserver <Integer > to = us .hide ()
826
+ .observeOn (Schedulers .io ())
827
+ .observeOn (Schedulers .single ())
828
+ .unsubscribeOn (Schedulers .computation ())
829
+ .firstOrError ()
830
+ .test ();
831
+
832
+ for (int i = 0 ; us .hasObservers () && i < 10000 ; i ++) {
833
+ us .onNext (i );
834
+ }
835
+
836
+ to
837
+ .awaitDone (5 , TimeUnit .SECONDS )
838
+ ;
839
+
840
+ if (!errors .isEmpty ()) {
841
+ throw new CompositeException (errors );
842
+ }
843
+
844
+ to .assertResult (0 );
845
+ } finally {
846
+ RxJavaPlugins .reset ();
847
+ }
848
+ }
849
+ }
818
850
}
You can’t perform that action at this time.
0 commit comments