File tree 1 file changed +18
-3
lines changed
rxjava-core/src/test/java/rx/subjects
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import static org .junit .Assert .assertEquals ;
19
19
20
- import java .util .ArrayList ;
21
- import java .util .Collections ;
22
- import java .util .List ;
20
+ import java .util .*;
23
21
import java .util .concurrent .CountDownLatch ;
24
22
import java .util .concurrent .TimeUnit ;
25
23
import java .util .concurrent .atomic .AtomicReference ;
32
30
import rx .Subscriber ;
33
31
import rx .Subscription ;
34
32
import rx .functions .Action1 ;
33
+ import rx .observers .TestSubscriber ;
34
+ import rx .schedulers .Schedulers ;
35
35
import rx .subscriptions .Subscriptions ;
36
36
37
37
public class ReplaySubjectConcurrencyTest {
@@ -303,6 +303,21 @@ public void run() {
303
303
}
304
304
305
305
}
306
+
307
+ /**
308
+ * https://github.com/Netflix/RxJava/issues/1147
309
+ */
310
+ @ Test
311
+ public void testRaceForTerminalState () {
312
+ final List <Integer > expected = Arrays .asList (1 );
313
+ for (int i = 0 ; i < 100000 ; i ++) {
314
+ TestSubscriber <Integer > ts = new TestSubscriber <Integer >();
315
+ Observable .just (1 ).subscribeOn (Schedulers .computation ()).cache ().subscribe (ts );
316
+ ts .awaitTerminalEvent ();
317
+ ts .assertReceivedOnNext (expected );
318
+ ts .assertTerminalEvent ();
319
+ }
320
+ }
306
321
307
322
private static class SubjectObserverThread extends Thread {
308
323
You can’t perform that action at this time.
0 commit comments