Skip to content

Commit 1cf5b9d

Browse files
authored
3.x: Remove Maybe.onExceptionResumeNext (#6844)
1 parent 9ed5416 commit 1cf5b9d

File tree

3 files changed

+4
-63
lines changed

3 files changed

+4
-63
lines changed

Diff for: src/main/java/io/reactivex/rxjava3/core/Maybe.java

+1-32
Original file line numberDiff line numberDiff line change
@@ -3939,7 +3939,7 @@ public final Maybe<T> onErrorResumeWith(@NonNull MaybeSource<? extends T> next)
39393939
@SchedulerSupport(SchedulerSupport.NONE)
39403940
public final Maybe<T> onErrorResumeNext(@NonNull Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction) {
39413941
Objects.requireNonNull(resumeFunction, "resumeFunction is null");
3942-
return RxJavaPlugins.onAssembly(new MaybeOnErrorNext<>(this, resumeFunction, true));
3942+
return RxJavaPlugins.onAssembly(new MaybeOnErrorNext<>(this, resumeFunction));
39433943
}
39443944

39453945
/**
@@ -3996,37 +3996,6 @@ public final Maybe<T> onErrorReturnItem(@NonNull T item) {
39963996
return onErrorReturn(Functions.justFunction(item));
39973997
}
39983998

3999-
/**
4000-
* Resumes the flow with the given {@link MaybeSource} when the current {@code Maybe} fails
4001-
* with an {@link Exception} subclass instead of signaling the error via {@code onError}.
4002-
* <p>
4003-
* This differs from {@link #onErrorResumeNext} in that this one does not handle {@link java.lang.Throwable}
4004-
* or {@link java.lang.Error} but lets those continue through.
4005-
* <p>
4006-
* <img width="640" height="333" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/onExceptionResumeNextViaMaybe.png" alt="">
4007-
* <p>
4008-
* You can use this to prevent exceptions from propagating or to supply fallback data should exceptions be
4009-
* encountered.
4010-
* <dl>
4011-
* <dt><b>Scheduler:</b></dt>
4012-
* <dd>{@code onExceptionResumeNext} does not operate by default on a particular {@link Scheduler}.</dd>
4013-
* </dl>
4014-
*
4015-
* @param next
4016-
* the next {@code MaybeSource} that will take over if the current {@code Maybe} encounters
4017-
* an exception
4018-
* @return the new {@code Maybe} instance
4019-
* @throws NullPointerException if {@code next} is {@code null}
4020-
* @see <a href="http://reactivex.io/documentation/operators/catch.html">ReactiveX operators documentation: Catch</a>
4021-
*/
4022-
@CheckReturnValue
4023-
@NonNull
4024-
@SchedulerSupport(SchedulerSupport.NONE)
4025-
public final Maybe<T> onExceptionResumeNext(@NonNull MaybeSource<? extends T> next) {
4026-
Objects.requireNonNull(next, "next is null");
4027-
return RxJavaPlugins.onAssembly(new MaybeOnErrorNext<>(this, Functions.justFunction(next), false));
4028-
}
4029-
40303999
/**
40314000
* Nulls out references to the upstream producer and downstream {@link MaybeObserver} if
40324001
* the sequence is terminated or downstream calls {@code dispose()}.

Diff for: src/main/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeOnErrorNext.java

+3-15
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,15 @@ public final class MaybeOnErrorNext<T> extends AbstractMaybeWithUpstream<T, T> {
3131

3232
final Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction;
3333

34-
final boolean allowFatal;
35-
3634
public MaybeOnErrorNext(MaybeSource<T> source,
37-
Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction,
38-
boolean allowFatal) {
35+
Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction) {
3936
super(source);
4037
this.resumeFunction = resumeFunction;
41-
this.allowFatal = allowFatal;
4238
}
4339

4440
@Override
4541
protected void subscribeActual(MaybeObserver<? super T> observer) {
46-
source.subscribe(new OnErrorNextMaybeObserver<>(observer, resumeFunction, allowFatal));
42+
source.subscribe(new OnErrorNextMaybeObserver<>(observer, resumeFunction));
4743
}
4844

4945
static final class OnErrorNextMaybeObserver<T>
@@ -56,14 +52,10 @@ static final class OnErrorNextMaybeObserver<T>
5652

5753
final Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction;
5854

59-
final boolean allowFatal;
60-
6155
OnErrorNextMaybeObserver(MaybeObserver<? super T> actual,
62-
Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction,
63-
boolean allowFatal) {
56+
Function<? super Throwable, ? extends MaybeSource<? extends T>> resumeFunction) {
6457
this.downstream = actual;
6558
this.resumeFunction = resumeFunction;
66-
this.allowFatal = allowFatal;
6759
}
6860

6961
@Override
@@ -90,10 +82,6 @@ public void onSuccess(T value) {
9082

9183
@Override
9284
public void onError(Throwable e) {
93-
if (!allowFatal && !(e instanceof Exception)) {
94-
downstream.onError(e);
95-
return;
96-
}
9785
MaybeSource<? extends T> m;
9886

9987
try {

Diff for: src/test/java/io/reactivex/rxjava3/internal/operators/maybe/MaybeOnErrorXTest.java

-16
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,6 @@ public void onErrorResumeNext() {
9898
.assertResult(1);
9999
}
100100

101-
@Test
102-
public void onExceptionResumeNext() {
103-
Maybe.error(new TestException())
104-
.onExceptionResumeNext(Maybe.just(1))
105-
.test()
106-
.assertResult(1);
107-
}
108-
109-
@Test
110-
public void onExceptionResumeNextPassthrough() {
111-
Maybe.error(new AssertionError())
112-
.onExceptionResumeNext(Maybe.just(1))
113-
.test()
114-
.assertFailure(AssertionError.class);
115-
}
116-
117101
@Test
118102
public void onErrorResumeNextFunctionThrows() {
119103
TestHelper.assertCompositeExceptions(Maybe.error(new TestException())

0 commit comments

Comments
 (0)