rx java - RxJava Can subscribe() on an Observable.empty() call onComplete() before the onSubscribe() returns a Subscription causing a NullPointerException? -


i writing logic merges 2 observables can make sure both run , complete whole. this, have used observable.mergedelayerror() seen below. however, when writing unit tests, sometimes, nullpointerexception when trying call mrefreshsubscription.unsubscribe() mrefreshsubscription null.

question: possible resulting merged observable, because can double empty, proceed call oncomplete() faster subscribe() returns subscription?

observable observa = observable.empty(); observable observb = observable.empty();  mrefreshsubscription = observable.mergedelayerror(observa, observb)                 .subscribeon(schedulers.io())                 .observeon(schedulers.io())                 .subscribe(getrefreshobserver());  private observer getrefreshobserver() {     if (mrefreshobserver == null) {         mrefreshobserver = new observer() {             @override             public void oncompleted() {                 mrefreshsubscription.unsubscribe();             }              @override             public void onerror(throwable e) {                 mrefreshsubscription.unsubscribe();             }              @override             public void onnext(object o) {                 // nothing             }         };     }     return mcleanandautosubscriberobserver; } 


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -