File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -7289,6 +7289,9 @@ public final void onNext(T args) {
7289
7289
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
7290
7290
*/
7291
7291
public final Subscription subscribe (final Observer <? super T > observer ) {
7292
+ if (observer instanceof Subscriber ) {
7293
+ return subscribe ((Subscriber <? super T >)observer );
7294
+ }
7292
7295
return subscribe (new Subscriber <T >() {
7293
7296
7294
7297
@ Override
Original file line number Diff line number Diff line change @@ -1129,4 +1129,13 @@ public void testEmptyIsEmpty() {
1129
1129
verify (w , never ()).onNext (any (Integer .class ));
1130
1130
verify (w , never ()).onError (any (Throwable .class ));
1131
1131
}
1132
+
1133
+ @ Test // cf. https://github.com/ReactiveX/RxJava/issues/2599
1134
+ public void testSubscribingSubscriberAsObserverMaintainsSubscriptionChain () {
1135
+ TestSubscriber <Object > subscriber = new TestSubscriber <Object >();
1136
+ Subscription subscription = Observable .just ("event" ).subscribe ((Observer <Object >) subscriber );
1137
+ subscription .unsubscribe ();
1138
+
1139
+ subscriber .assertUnsubscribed ();
1140
+ }
1132
1141
}
You can’t perform that action at this time.
0 commit comments