The mapper function returned a null value.
See original GitHub issueThanks for this library!
I upgraded RxJava to 2.x in my Android app and now I get an error:
NullPointerException: the mapper function returned a null value
. Exception is thrown by ObjectHelper
.
It appear inside this part of code (FlowableMap.java):
return t != null ? ObjectHelper.<U>requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null;
Seems that mapper.apply(t)
return null…
I call onNext using enum object
public class SystemBus {
private PublishProcessor<SystemEvent> mSystemEventPublishSubject;
SystemBus() {
mSystemEventPublishSubject = PublishProcessor.create();
}
public void onNext(SystemEvent systemEvent) {
mSystemEventPublishSubject.onNext(systemEvent); // ---> this line lead to an error
}
public PublishProcessor<SystemEvent> getObservable() {
return mSystemEventPublishSubject;
}
}
Also SystemEvent class :
public enum SystemEvent {
FINISH_ACTIVITY,
PERMISSIONS_REQUEST,
PERMISSIONS_RESPONSE,
UPDATE_CARDS,
PDL,
MENU_REFRESH
}
Here the stack trace:
Fatal Exception: io.reactivex.exceptions.OnErrorNotImplementedException: The mapper function returned a null value.
at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
at io.reactivex.internal.subscribers.LambdaSubscriber.onError(LambdaSubscriber.java:79)
at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onError(BasicFuseableSubscriber.java:101)
at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.onError(BasicFuseableConditionalSubscriber.java:100)
at io.reactivex.internal.subscribers.BasicFuseableConditionalSubscriber.fail(BasicFuseableConditionalSubscriber.java:110)
at io.reactivex.internal.operators.flowable.FlowableMap$MapConditionalSubscriber.tryOnNext(FlowableMap.java:126)
at io.reactivex.internal.operators.flowable.FlowableFilter$FilterConditionalSubscriber.tryOnNext(FlowableFilter.java:141)
at io.reactivex.internal.operators.flowable.FlowableFilter$FilterConditionalSubscriber.onNext(FlowableFilter.java:119)
at io.reactivex.processors.PublishProcessor$PublishSubscription.onNext(PublishProcessor.java:315)
at io.reactivex.processors.PublishProcessor.onNext(PublishProcessor.java:197)
at ai.#####.SystemBus.onNext(SystemBus.java:20)
at ai.#####.App$2.onReceive(App.java:151)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:922)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by java.lang.NullPointerException: The mapper function returned a null value.
at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39)
at io.reactivex.internal.operators.flowable.FlowableMap$MapConditionalSubscriber.tryOnNext(FlowableMap.java:124)
at io.reactivex.internal.operators.flowable.FlowableFilter$FilterConditionalSubscriber.tryOnNext(FlowableFilter.java:141)
at io.reactivex.internal.operators.flowable.FlowableFilter$FilterConditionalSubscriber.onNext(FlowableFilter.java:119)
at io.reactivex.processors.PublishProcessor$PublishSubscription.onNext(PublishProcessor.java:315)
at io.reactivex.processors.PublishProcessor.onNext(PublishProcessor.java:197)
at ai.#####.SystemBus.onNext(SystemBus.java:20)
at ai.#####.App$2.onReceive(App.java:151)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:922)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
The mapper function returned a null value - Stack Overflow
The problem comes from RxJava 2, which won't allow null values to be passed down the stream. In particularly your case, you have...
Read more >THE MAPPER FUNCTION RETURNED A NULL VALUE
THE MAPPER FUNCTION RETURNED A NULL VALUE. Watch later. Share. Copy link. Info. Shopping. Tap to unmute. If playback doesn't begin shortly, ...
Read more >io.reactivex.functions.Function java code examples - Tabnine
A functional interface that takes a value and returns another value, possibly with a different type and allows throwing a checked exception. Most...
Read more >RxDogTag - Uber Open Source
NullPointerException : The mapper function returned a null value. at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39) at ...
Read more >FluxMap 报错: The mapper returned a null value - CSDN博客
在进行Flux的map操作时如果返回的是一个空值,会报错: The mapper returned a null value. 原因是在map操作返回时,会对返回值进行非空校验原本希望 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nulls are not allowed in 2.x. Check your mapper function why it returns null.
You could use the function tagging support in the extensions project, or simply define your lambdas in a way that throw on null return: