-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Labels
Milestone
Description
RxJava 2.0.7
The BiConsumer
interface has both parameters of its accept()
method marked as @NonNull
. However, when using the BiConsumer
interface as result callback for a Single
, the received parameter values are mutually exclusive being a non-null value and the other one being null
. Although it seems to make sense in use, it violates the interface annotations and makes usage, at least, confusing.
Single.just("Some string")
.subscribe(new BiConsumer<String, Throwable>() {
@Override
public void accept(@io.reactivex.annotations.NonNull String s, @io.reactivex.annotations.NonNull Throwable throwable) throws Exception {
assert s != null;
assert throwable == null;
}
});
Single.<String>error(new RuntimeException())
.subscribe(new BiConsumer<String, Throwable>() {
@Override
public void accept(@io.reactivex.annotations.NonNull String s, @io.reactivex.annotations.NonNull Throwable throwable) throws Exception {
assert s == null;
assert throwable != null;
}
});