File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ public void onNext(T t) {
8080 }
8181 };
8282 child .add (parent );
83- observable .subscribe (parent );
83+ observable .unsafeSubscribe (parent );
8484 }
8585
8686 public static <T > OnSubscribeSingle <T > create (Observable <T > observable ) {
Original file line number Diff line number Diff line change 1515 */
1616package rx .internal .operators ;
1717
18+ import static org .junit .Assert .assertFalse ;
19+
20+ import java .util .Collections ;
21+ import java .util .NoSuchElementException ;
22+ import java .util .concurrent .atomic .AtomicBoolean ;
23+
1824import org .junit .Test ;
25+
1926import rx .Observable ;
2027import rx .Single ;
28+ import rx .functions .Action0 ;
2129import rx .observers .TestSubscriber ;
2230
23- import java .util .Collections ;
24- import java .util .NoSuchElementException ;
25-
2631public class OnSubscribeSingleTest {
2732
2833 @ Test
@@ -70,4 +75,19 @@ public void testRepeatObservableThrowsError() {
7075
7176 subscriber .assertError (IllegalArgumentException .class );
7277 }
78+
79+ @ Test
80+ public void testShouldUseUnsafeSubscribeInternallyNotSubscribe () {
81+ TestSubscriber <String > subscriber = TestSubscriber .create ();
82+ final AtomicBoolean unsubscribed = new AtomicBoolean (false );
83+ Single <String > single = Observable .just ("Hello World!" ).doOnUnsubscribe (new Action0 () {
84+
85+ @ Override
86+ public void call () {
87+ unsubscribed .set (true );
88+ }}).toSingle ();
89+ single .unsafeSubscribe (subscriber );
90+ subscriber .assertCompleted ();
91+ assertFalse (unsubscribed .get ());
92+ }
7393}
You can’t perform that action at this time.
0 commit comments