File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,10 @@ public void onNext(T t) {
64
64
65
65
@ Override
66
66
public void onError (Throwable e ) {
67
- child .onError (e );
67
+ if (!done ) {
68
+ done = true ;
69
+ child .onError (e );
70
+ }
68
71
}
69
72
70
73
@ Override
Original file line number Diff line number Diff line change 25
25
import org .junit .Test ;
26
26
27
27
import rx .*;
28
+ import rx .Observable .OnSubscribe ;
28
29
import rx .functions .Func1 ;
29
30
import rx .internal .util .UtilityFunctions ;
30
31
import rx .observers .TestSubscriber ;
@@ -270,4 +271,35 @@ public Boolean call(Object object) {
270
271
assertEquals (ex , errors .get (0 ));
271
272
assertTrue (ex .getCause ().getMessage ().contains ("Boo!" ));
272
273
}
274
+
275
+
276
+ @ Test
277
+ public void testDoesNotEmitMultipleTerminalEvents () {
278
+ TestSubscriber <Boolean > ts = TestSubscriber .create ();
279
+ Observable .create (new OnSubscribe <Integer >() {
280
+
281
+ @ Override
282
+ public void call (final Subscriber <? super Integer > sub ) {
283
+ sub .setProducer (new Producer () {
284
+
285
+ @ Override
286
+ public void request (long n ) {
287
+ if (n > 0 ) {
288
+ sub .onNext (1 );
289
+ sub .onCompleted ();
290
+ }
291
+ }
292
+ });
293
+ }
294
+ })
295
+ .exists (new Func1 <Integer ,Boolean >() {
296
+
297
+ @ Override
298
+ public Boolean call (Integer t ) {
299
+ throw new RuntimeException ("boo" );
300
+ }})
301
+ .unsafeSubscribe (ts );
302
+ ts .assertError (RuntimeException .class );
303
+ ts .assertNotCompleted ();
304
+ }
273
305
}
You can’t perform that action at this time.
0 commit comments