File tree 1 file changed +13
-2
lines changed
rxjava-core/src/main/java/rx 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -6900,9 +6900,20 @@ public final Subscription subscribe(Subscriber<? super T> observer) {
6900
6900
if (isInternalImplementation (observer )) {
6901
6901
onSubscribeFunction .call (observer );
6902
6902
} else {
6903
- onSubscribeFunction .call (new SafeSubscriber <T >(observer ));
6903
+ // assign to `observer` so we return the protected version
6904
+ observer = new SafeSubscriber <T >(observer );
6905
+ onSubscribeFunction .call (observer );
6904
6906
}
6905
- return hook .onSubscribeReturn (this , observer );
6907
+ final Subscription returnSubscription = hook .onSubscribeReturn (this , observer );
6908
+ // we return it inside a Subscription so it can't be cast back to Subscriber
6909
+ return Subscriptions .create (new Action0 () {
6910
+
6911
+ @ Override
6912
+ public void call () {
6913
+ returnSubscription .unsubscribe ();
6914
+ }
6915
+
6916
+ });
6906
6917
} catch (OnErrorNotImplementedException e ) {
6907
6918
// special handling when onError is not implemented ... we just rethrow
6908
6919
throw e ;
You can’t perform that action at this time.
0 commit comments