File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/test/java/rx/internal/operators Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,13 @@ public void call() {
270
270
s .assertNoErrors ();
271
271
}
272
272
273
+ @ Test
274
+ public void testConnectUnsubscribeRaceConditionLoop () throws InterruptedException {
275
+ for (int i = 0 ; i < 1000 ; i ++) {
276
+ testConnectUnsubscribeRaceCondition ();
277
+ }
278
+ }
279
+
273
280
@ Test
274
281
public void testConnectUnsubscribeRaceCondition () throws InterruptedException {
275
282
final AtomicInteger subUnsubCount = new AtomicInteger ();
@@ -295,12 +302,14 @@ public void call() {
295
302
});
296
303
297
304
TestSubscriber <Long > s = new TestSubscriber <Long >();
298
- o .publish ().refCount ().subscribeOn (Schedulers .newThread ()).subscribe (s );
305
+
306
+ o .publish ().refCount ().subscribeOn (Schedulers .computation ()).subscribe (s );
299
307
System .out .println ("send unsubscribe" );
300
308
// now immediately unsubscribe while subscribeOn is racing to subscribe
301
309
s .unsubscribe ();
302
310
// this generally will mean it won't even subscribe as it is already unsubscribed by the time connect() gets scheduled
303
-
311
+ // give time to the counter to update
312
+ Thread .sleep (1 );
304
313
// either we subscribed and then unsubscribed, or we didn't ever even subscribe
305
314
assertEquals (0 , subUnsubCount .get ());
306
315
You can’t perform that action at this time.
0 commit comments