File tree 1 file changed +13
-1
lines changed
rxjava-core/src/test/java/rx/subjects
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,8 @@ public void onNext(String v) {
311
311
subject .onNext ("two" );
312
312
assertEquals ("two" , lastValueForObserver1 .get ());
313
313
314
- Subscription s2 = subject .observeOn (Schedulers .newThread ()).subscribe (observer2 );
314
+ // use subscribeOn to make this async otherwise we deadlock as we are using CountDownLatches
315
+ Subscription s2 = subject .subscribeOn (Schedulers .newThread ()).subscribe (observer2 );
315
316
316
317
System .out .println ("before waiting for one" );
317
318
@@ -321,12 +322,23 @@ public void onNext(String v) {
321
322
System .out .println ("after waiting for one" );
322
323
323
324
subject .onNext ("three" );
325
+
326
+ System .out .println ("sent three" );
327
+
324
328
// if subscription blocked existing subscribers then 'makeSlow' would cause this to not be there yet
325
329
assertEquals ("three" , lastValueForObserver1 .get ());
330
+
331
+ System .out .println ("about to send onCompleted" );
332
+
326
333
subject .onCompleted ();
327
334
335
+ System .out .println ("completed subject" );
336
+
328
337
// release
329
338
makeSlow .countDown ();
339
+
340
+ System .out .println ("makeSlow released" );
341
+
330
342
completed .await ();
331
343
// all of them should be emitted with the last being "three"
332
344
assertEquals ("three" , lastValueForObserver2 .get ());
You can’t perform that action at this time.
0 commit comments