@@ -628,26 +628,42 @@ public static <T> Maybe<T> fromSingle(SingleSource<T> singleSource) {
628
628
}
629
629
630
630
/**
631
- * Returns a {@link Maybe} that invokes passed function and emits its result for each new MaybeObserver that subscribes
632
- * while considering {@code null} value from the callable as indication for valueless completion.
631
+ * Returns a {@link Maybe} that invokes the given {@link Callable} for each individual {@link MaybeObserver} that
632
+ * subscribes and emits the resulting non-null item via {@code onSuccess} while
633
+ * considering a {@code null} result from the {@code Callable} as indication for valueless completion
634
+ * via {@code onComplete}.
633
635
* <p>
634
- * Allows you to defer execution of passed function until MaybeObserver subscribes to the {@link Maybe}.
635
- * It makes passed function "lazy".
636
- * Result of the function invocation will be emitted by the {@link Maybe}.
636
+ * This operator allows you to defer the execution of the given {@code Callable} until a {@code MaybeObserver}
637
+ * subscribes to the returned {@link Maybe}. In other terms, this source operator evaluates the given
638
+ * {@code Callable} "lazily".
639
+ * <p>
640
+ * Note that the {@code null} handling of this operator differs from the similar source operators in the other
641
+ * {@link io.reactivex base reactive classes}. Those operators signal a {@code NullPointerException} if the value returned by their
642
+ * {@code Callable} is {@code null} while this {@code fromCallable} considers it to indicate the
643
+ * returned {@code Maybe} is empty.
637
644
* <dl>
638
645
* <dt><b>Scheduler:</b></dt>
639
646
* <dd>{@code fromCallable} does not operate by default on a particular {@link Scheduler}.</dd>
647
+ * <dt><b>Error handling:</b></dt>
648
+ * <dd>Any non-fatal exception thrown by {@link Callable#call()} will be forwarded to {@code onError},
649
+ * except if the {@code MaybeObserver} disposed the subscription in the meantime. In this latter case,
650
+ * the exception is forwarded to the global error handler via
651
+ * {@link io.reactivex.plugins.RxJavaPlugins#onError(Throwable)} wrapped into a
652
+ * {@link io.reactivex.exceptions.UndeliverableException UndeliverableException}.
653
+ * Fatal exceptions are rethrown and usually will end up in the executing thread's
654
+ * {@link java.lang.Thread.UncaughtExceptionHandler#uncaughtException(Thread, Throwable)} handler.</dd>
640
655
* </dl>
641
656
*
642
657
* @param callable
643
- * function which execution should be deferred, it will be invoked when MaybeObserver will subscribe to the {@link Maybe}.
658
+ * a {@link Callable} instance whose execution should be deferred and performed for each individual
659
+ * {@code MaybeObserver} that subscribes to the returned {@link Maybe}.
644
660
* @param <T>
645
661
* the type of the item emitted by the {@link Maybe}.
646
- * @return a {@link Maybe} whose {@link MaybeObserver}s' subscriptions trigger an invocation of the given function.
662
+ * @return a new Maybe instance
647
663
*/
648
664
@ CheckReturnValue
649
665
@ SchedulerSupport (SchedulerSupport .NONE )
650
- public static <T > Maybe <T > fromCallable (final Callable <? extends T > callable ) {
666
+ public static <T > Maybe <T > fromCallable (@ NonNull final Callable <? extends T > callable ) {
651
667
ObjectHelper .requireNonNull (callable , "callable is null" );
652
668
return RxJavaPlugins .onAssembly (new MaybeFromCallable <T >(callable ));
653
669
}
0 commit comments