Skip to content

2.x: WithLatestFrom not calling onSubscribe() on actual observer #4969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ZacSweers opened this issue Jan 8, 2017 · 4 comments
Closed

2.x: WithLatestFrom not calling onSubscribe() on actual observer #4969

ZacSweers opened this issue Jan 8, 2017 · 4 comments

Comments

@ZacSweers
Copy link
Contributor

ZacSweers commented Jan 8, 2017

We're seeing an NPE from the s field of SerializedObserver not being set when used with .withLatestFrom(). Digging around in the source, it looks like it internally is not calling onSubscribe() to the actual observer field.

Example trace looks like this:

java.lang.NullPointerException
	at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:91)
	at io.reactivex.internal.operators.observable.ObservableWithLatestFrom$WithLatestFromObserver.onNext(ObservableWithLatestFrom.java:101)
	at io.reactivex.internal.operators.observable.ObservableFilter$FilterObserver.onNext(ObservableFilter.java:51)
	at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:63)
	at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:263)
	at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:182)

The snippet in SerializedObserver that corresponds to

    @Override
    public void onNext(T t) {
        if (done) {
            return;
        }
        if (t == null) {
            s.dispose();  // <----- this line, "s" is null because onSubscribe was never called
            onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
            return;
        }
@ZacSweers
Copy link
Contributor Author

Specifically, the static WithLatestFromObserver class in ObservableWithLatestFrom never calls OnSubscribe on its actual before sending other events to it.

@akarnokd
Copy link
Member

akarnokd commented Jan 8, 2017

The main problem is that withLatestFrom doesn't check for null returned by the combiner. I'll post a PR shortly.

@ZacSweers
Copy link
Contributor Author

👍 thanks!

@akarnokd akarnokd added this to the 2.0 backlog milestone Jan 8, 2017
@ZacSweers
Copy link
Contributor Author

Fixed in #4970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants