Skip to content

Commit 879a04c

Browse files
gracefully handle null subscription on trusted onSubscribe the same as non-trusted already does
1 parent b29508a commit 879a04c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,14 @@ public Subscription subscribe(Observer<T> observer) {
157157
// the subscribe function can also be overridden but generally that's not the appropriate approach so I won't mention that in the exception
158158
}
159159
if (isTrusted) {
160-
return onSubscribe.call(observer);
160+
Subscription s = onSubscribe.call(observer);
161+
if (s == null) {
162+
// this generally shouldn't be the case on a 'trusted' onSubscribe but in case it happens
163+
// we want to gracefully handle it the same as AtomicObservableSubscription does
164+
return Subscriptions.empty();
165+
} else {
166+
return s;
167+
}
161168
} else {
162169
AtomicObservableSubscription subscription = new AtomicObservableSubscription();
163170
return subscription.wrap(onSubscribe.call(new AtomicObserver<T>(subscription, observer)));

0 commit comments

Comments
 (0)