File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,10 @@ public void onNext(T t) {
61
61
62
62
@ Override
63
63
public void onError (Throwable e ) {
64
- child .onError (e );
64
+ if (!done ) {
65
+ done = true ;
66
+ child .onError (e );
67
+ }
65
68
}
66
69
67
70
@ 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 .observers .TestSubscriber ;
30
31
@@ -178,4 +179,34 @@ public Boolean call(Object object) {
178
179
assertEquals (ex , errors .get (0 ));
179
180
assertTrue (ex .getCause ().getMessage ().contains ("Boo!" ));
180
181
}
182
+
183
+ @ Test
184
+ public void testDoesNotEmitMultipleTerminalEvents () {
185
+ TestSubscriber <Boolean > ts = TestSubscriber .create ();
186
+ Observable .create (new OnSubscribe <Integer >() {
187
+
188
+ @ Override
189
+ public void call (final Subscriber <? super Integer > sub ) {
190
+ sub .setProducer (new Producer () {
191
+
192
+ @ Override
193
+ public void request (long n ) {
194
+ if (n > 0 ) {
195
+ sub .onNext (1 );
196
+ sub .onCompleted ();
197
+ }
198
+ }
199
+ });
200
+ }
201
+ })
202
+ .all (new Func1 <Integer ,Boolean >() {
203
+
204
+ @ Override
205
+ public Boolean call (Integer t ) {
206
+ throw new RuntimeException ("boo" );
207
+ }})
208
+ .unsafeSubscribe (ts );
209
+ ts .assertError (RuntimeException .class );
210
+ ts .assertNotCompleted ();
211
+ }
181
212
}
You can’t perform that action at this time.
0 commit comments