File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
main/java/io/reactivex/internal/operators/single
test/java/io/reactivex/internal/operators Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ public void onSubscribe(Subscription s) {
147
147
@ Override
148
148
public void onNext (Object t ) {
149
149
if (SubscriptionHelper .cancel (this )) {
150
- onComplete ( );
150
+ parent . otherError ( new CancellationException () );
151
151
}
152
152
}
153
153
@@ -158,7 +158,10 @@ public void onError(Throwable t) {
158
158
159
159
@ Override
160
160
public void onComplete () {
161
- parent .otherError (new CancellationException ());
161
+ if (get () != SubscriptionHelper .CANCELLED ) {
162
+ lazySet (SubscriptionHelper .CANCELLED );
163
+ parent .otherError (new CancellationException ());
164
+ }
162
165
}
163
166
164
167
public void dispose () {
Original file line number Diff line number Diff line change @@ -184,4 +184,18 @@ public void run() {
184
184
to .assertResult ();
185
185
}
186
186
}
187
+
188
+ @ Test
189
+ public void otherSignalsAndCompletes () {
190
+ List <Throwable > errors = TestHelper .trackPluginErrors ();
191
+ try {
192
+ Maybe .just (1 ).takeUntil (Flowable .just (1 ).take (1 ))
193
+ .test ()
194
+ .assertResult ();
195
+
196
+ assertTrue (errors .toString (), errors .isEmpty ());
197
+ } finally {
198
+ RxJavaPlugins .reset ();
199
+ }
200
+ }
187
201
}
Original file line number Diff line number Diff line change 16
16
import java .util .List ;
17
17
import java .util .concurrent .CancellationException ;
18
18
19
+ import static org .junit .Assert .*;
19
20
import org .junit .Test ;
20
21
21
22
import io .reactivex .*;
@@ -259,4 +260,18 @@ public void run() {
259
260
}
260
261
}
261
262
}
263
+
264
+ @ Test
265
+ public void otherSignalsAndCompletes () {
266
+ List <Throwable > errors = TestHelper .trackPluginErrors ();
267
+ try {
268
+ Single .just (1 ).takeUntil (Flowable .just (1 ).take (1 ))
269
+ .test ()
270
+ .assertFailure (CancellationException .class );
271
+
272
+ assertTrue (errors .toString (), errors .isEmpty ());
273
+ } finally {
274
+ RxJavaPlugins .reset ();
275
+ }
276
+ }
262
277
}
You can’t perform that action at this time.
0 commit comments