Skip to content

Commit 0b3558d

Browse files
BharathMGakarnokd
authored andcommitted
Undeliverable error handling logic for Completable operators (#6442)
* Error handle on Completable.fromAction with RxJavaPlugins * Error handle on Completable.fromRunnable with RxJavaPlugins * Added error handling java docs section to Completable.fromRunnable
1 parent b0cb174 commit 0b3558d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: src/main/java/io/reactivex/Completable.java

+7
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,13 @@ public static <T> Completable fromMaybe(final MaybeSource<T> maybe) {
508508
* <dl>
509509
* <dt><b>Scheduler:</b></dt>
510510
* <dd>{@code fromRunnable} does not operate by default on a particular {@link Scheduler}.</dd>
511+
* <dt><b>Error handling:</b></dt>
512+
* <dd> If the {@link Runnable} throws an exception, the respective {@link Throwable} is
513+
* delivered to the downstream via {@link CompletableObserver#onError(Throwable)},
514+
* except when the downstream has disposed this {@code Completable} source.
515+
* In this latter case, the {@code Throwable} is delivered to the global error handler via
516+
* {@link RxJavaPlugins#onError(Throwable)} as an {@link io.reactivex.exceptions.UndeliverableException UndeliverableException}.
517+
* </dd>
511518
* </dl>
512519
* @param run the runnable to run for each subscriber
513520
* @return the new Completable instance

Diff for: src/main/java/io/reactivex/internal/operators/completable/CompletableFromAction.java

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.reactivex.disposables.*;
1818
import io.reactivex.exceptions.Exceptions;
1919
import io.reactivex.functions.Action;
20+
import io.reactivex.plugins.RxJavaPlugins;
2021

2122
public final class CompletableFromAction extends Completable {
2223

@@ -36,6 +37,8 @@ protected void subscribeActual(CompletableObserver observer) {
3637
Exceptions.throwIfFatal(e);
3738
if (!d.isDisposed()) {
3839
observer.onError(e);
40+
} else {
41+
RxJavaPlugins.onError(e);
3942
}
4043
return;
4144
}

Diff for: src/main/java/io/reactivex/internal/operators/completable/CompletableFromRunnable.java

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io.reactivex.disposables.Disposable;
1919
import io.reactivex.disposables.Disposables;
2020
import io.reactivex.exceptions.Exceptions;
21+
import io.reactivex.plugins.RxJavaPlugins;
2122

2223
public final class CompletableFromRunnable extends Completable {
2324

@@ -37,6 +38,8 @@ protected void subscribeActual(CompletableObserver observer) {
3738
Exceptions.throwIfFatal(e);
3839
if (!d.isDisposed()) {
3940
observer.onError(e);
41+
} else {
42+
RxJavaPlugins.onError(e);
4043
}
4144
return;
4245
}

0 commit comments

Comments
 (0)