File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
rxjava-core/src/test/java/rx/subjects Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 1717
1818import static org .junit .Assert .assertEquals ;
1919
20- import java .util .ArrayList ;
21- import java .util .Collections ;
22- import java .util .List ;
20+ import java .util .*;
2321import java .util .concurrent .CountDownLatch ;
2422import java .util .concurrent .TimeUnit ;
2523import java .util .concurrent .atomic .AtomicReference ;
3230import rx .Subscriber ;
3331import rx .Subscription ;
3432import rx .functions .Action1 ;
33+ import rx .observers .TestSubscriber ;
34+ import rx .schedulers .Schedulers ;
3535import rx .subscriptions .Subscriptions ;
3636
3737public class ReplaySubjectConcurrencyTest {
@@ -303,6 +303,21 @@ public void run() {
303303 }
304304
305305 }
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+ }
306321
307322 private static class SubjectObserverThread extends Thread {
308323
You can’t perform that action at this time.
0 commit comments