Skip to content

Commit bc1c705

Browse files
authored
2.x: add error handling section to merge() operator docs (#5786)
* 2.x: add error handling section to merge() operator docs * Change to "UndeliverableException errors"
1 parent d91ee5a commit bc1c705

File tree

5 files changed

+503
-5
lines changed

5 files changed

+503
-5
lines changed

src/main/java/io/reactivex/Completable.java

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,23 @@ public static <T> Completable fromSingle(final SingleSource<T> single) {
451451
* <dl>
452452
* <dt><b>Scheduler:</b></dt>
453453
* <dd>{@code mergeArray} does not operate by default on a particular {@link Scheduler}.</dd>
454+
* <dd>If any of the source {@code CompletableSource}s signal a {@code Throwable} via {@code onError}, the resulting
455+
* {@code Completable} terminates with that {@code Throwable} and all other source {@code CompletableSource}s are cancelled.
456+
* If more than one {@code CompletableSource} signals an error, the resulting {@code Completable} may terminate with the
457+
* first one's error or, depending on the concurrency of the sources, may terminate with a
458+
* {@code CompositeException} containing two or more of the various error signals.
459+
* {@code Throwable}s that didn't make into the composite will be sent (individually) to the global error handler via
460+
* {@link RxJavaPlugins#onError(Throwable)} method as {@code UndeliverableException} errors. Similarly, {@code Throwable}s
461+
* signaled by source(s) after the returned {@code Completable} has been cancelled or terminated with a
462+
* (composite) error will be sent to the same global error handler.
463+
* Use {@link #mergeArrayDelayError(CompletableSource...)} to merge sources and terminate only when all source {@code CompletableSource}s
464+
* have completed or failed with an error.
465+
* </dd>
454466
* </dl>
455467
* @param sources the iterable sequence of sources.
456468
* @return the new Completable instance
457469
* @throws NullPointerException if sources is null
470+
* @see #mergeArrayDelayError(CompletableSource...)
458471
*/
459472
@CheckReturnValue
460473
@SchedulerSupport(SchedulerSupport.NONE)
@@ -475,10 +488,24 @@ public static Completable mergeArray(CompletableSource... sources) {
475488
* <dl>
476489
* <dt><b>Scheduler:</b></dt>
477490
* <dd>{@code merge} does not operate by default on a particular {@link Scheduler}.</dd>
491+
* <dt><b>Error handling:</b></dt>
492+
* <dd>If any of the source {@code CompletableSource}s signal a {@code Throwable} via {@code onError}, the resulting
493+
* {@code Completable} terminates with that {@code Throwable} and all other source {@code CompletableSource}s are cancelled.
494+
* If more than one {@code CompletableSource} signals an error, the resulting {@code Completable} may terminate with the
495+
* first one's error or, depending on the concurrency of the sources, may terminate with a
496+
* {@code CompositeException} containing two or more of the various error signals.
497+
* {@code Throwable}s that didn't make into the composite will be sent (individually) to the global error handler via
498+
* {@link RxJavaPlugins#onError(Throwable)} method as {@code UndeliverableException} errors. Similarly, {@code Throwable}s
499+
* signaled by source(s) after the returned {@code Completable} has been cancelled or terminated with a
500+
* (composite) error will be sent to the same global error handler.
501+
* Use {@link #mergeDelayError(Iterable)} to merge sources and terminate only when all source {@code CompletableSource}s
502+
* have completed or failed with an error.
503+
* </dd>
478504
* </dl>
479505
* @param sources the iterable sequence of sources.
480506
* @return the new Completable instance
481507
* @throws NullPointerException if sources is null
508+
* @see #mergeDelayError(Iterable)
482509
*/
483510
@CheckReturnValue
484511
@SchedulerSupport(SchedulerSupport.NONE)
@@ -496,10 +523,23 @@ public static Completable merge(Iterable<? extends CompletableSource> sources) {
496523
* and expects the other {@code Publisher} to honor it as well.</dd>
497524
* <dt><b>Scheduler:</b></dt>
498525
* <dd>{@code merge} does not operate by default on a particular {@link Scheduler}.</dd>
526+
* <dd>If any of the source {@code CompletableSource}s signal a {@code Throwable} via {@code onError}, the resulting
527+
* {@code Completable} terminates with that {@code Throwable} and all other source {@code CompletableSource}s are cancelled.
528+
* If more than one {@code CompletableSource} signals an error, the resulting {@code Completable} may terminate with the
529+
* first one's error or, depending on the concurrency of the sources, may terminate with a
530+
* {@code CompositeException} containing two or more of the various error signals.
531+
* {@code Throwable}s that didn't make into the composite will be sent (individually) to the global error handler via
532+
* {@link RxJavaPlugins#onError(Throwable)} method as {@code UndeliverableException} errors. Similarly, {@code Throwable}s
533+
* signaled by source(s) after the returned {@code Completable} has been cancelled or terminated with a
534+
* (composite) error will be sent to the same global error handler.
535+
* Use {@link #mergeDelayError(Publisher)} to merge sources and terminate only when all source {@code CompletableSource}s
536+
* have completed or failed with an error.
537+
* </dd>
499538
* </dl>
500539
* @param sources the iterable sequence of sources.
501540
* @return the new Completable instance
502541
* @throws NullPointerException if sources is null
542+
* @see #mergeDelayError(Publisher)
503543
*/
504544
@CheckReturnValue
505545
@SchedulerSupport(SchedulerSupport.NONE)
@@ -517,12 +557,25 @@ public static Completable merge(Publisher<? extends CompletableSource> sources)
517557
* and expects the other {@code Publisher} to honor it as well.</dd>
518558
* <dt><b>Scheduler:</b></dt>
519559
* <dd>{@code merge} does not operate by default on a particular {@link Scheduler}.</dd>
560+
* <dd>If any of the source {@code CompletableSource}s signal a {@code Throwable} via {@code onError}, the resulting
561+
* {@code Completable} terminates with that {@code Throwable} and all other source {@code CompletableSource}s are cancelled.
562+
* If more than one {@code CompletableSource} signals an error, the resulting {@code Completable} may terminate with the
563+
* first one's error or, depending on the concurrency of the sources, may terminate with a
564+
* {@code CompositeException} containing two or more of the various error signals.
565+
* {@code Throwable}s that didn't make into the composite will be sent (individually) to the global error handler via
566+
* {@link RxJavaPlugins#onError(Throwable)} method as {@code UndeliverableException} errors. Similarly, {@code Throwable}s
567+
* signaled by source(s) after the returned {@code Completable} has been cancelled or terminated with a
568+
* (composite) error will be sent to the same global error handler.
569+
* Use {@link #mergeDelayError(Publisher, int)} to merge sources and terminate only when all source {@code CompletableSource}s
570+
* have completed or failed with an error.
571+
* </dd>
520572
* </dl>
521573
* @param sources the iterable sequence of sources.
522574
* @param maxConcurrency the maximum number of concurrent subscriptions
523575
* @return the new Completable instance
524576
* @throws NullPointerException if sources is null
525577
* @throws IllegalArgumentException if maxConcurrency is less than 1
578+
* @see #mergeDelayError(Publisher, int)
526579
*/
527580
@CheckReturnValue
528581
@SchedulerSupport(SchedulerSupport.NONE)
@@ -1253,7 +1306,7 @@ public final Completable doOnSubscribe(Consumer<? super Disposable> onSubscribe)
12531306

12541307
/**
12551308
* Returns a Completable instance that calls the given onTerminate callback just before this Completable
1256-
* completes normally or with an exception
1309+
* completes normally or with an exception.
12571310
* <dl>
12581311
* <dt><b>Scheduler:</b></dt>
12591312
* <dd>{@code doOnTerminate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -1272,7 +1325,7 @@ public final Completable doOnTerminate(final Action onTerminate) {
12721325

12731326
/**
12741327
* Returns a Completable instance that calls the given onTerminate callback after this Completable
1275-
* completes normally or with an exception
1328+
* completes normally or with an exception.
12761329
* <dl>
12771330
* <dt><b>Scheduler:</b></dt>
12781331
* <dd>{@code doAfterTerminate} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -2084,7 +2137,7 @@ public final <T> Single<T> toSingleDefault(final T completionValue) {
20842137

20852138
/**
20862139
* Returns a Completable which makes sure when a subscriber cancels the subscription, the
2087-
* dispose is called on the specified scheduler
2140+
* dispose is called on the specified scheduler.
20882141
* <dl>
20892142
* <dt><b>Scheduler:</b></dt>
20902143
* <dd>{@code unsubscribeOn} calls dispose() of the upstream on the {@link Scheduler} you specify.</dd>

0 commit comments

Comments
 (0)