Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/main/java/io/reactivex/rxjava3/core/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2996,11 +2996,7 @@ public final Disposable subscribe(
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable subscribe(@NonNull Action onComplete) {
Objects.requireNonNull(onComplete, "onComplete is null");

CallbackCompletableObserver observer = new CallbackCompletableObserver(onComplete);
subscribe(observer);
return observer;
return subscribe(onComplete, Functions.ON_ERROR_MISSING);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,24 @@
import io.reactivex.rxjava3.exceptions.*;
import io.reactivex.rxjava3.functions.*;
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
import io.reactivex.rxjava3.internal.functions.Functions;
import io.reactivex.rxjava3.observers.LambdaConsumerIntrospection;
import io.reactivex.rxjava3.plugins.RxJavaPlugins;

public final class CallbackCompletableObserver
extends AtomicReference<Disposable>
implements CompletableObserver, Disposable, Consumer<Throwable>, LambdaConsumerIntrospection {
implements CompletableObserver, Disposable, LambdaConsumerIntrospection {

private static final long serialVersionUID = -4361286194466301354L;

final Consumer<? super Throwable> onError;
final Action onComplete;

public CallbackCompletableObserver(Action onComplete) {
this.onError = this;
this.onComplete = onComplete;
}

public CallbackCompletableObserver(Consumer<? super Throwable> onError, Action onComplete) {
this.onError = onError;
this.onComplete = onComplete;
}

@Override
public void accept(Throwable e) {
RxJavaPlugins.onError(new OnErrorNotImplementedException(e));
}

@Override
public void onComplete() {
try {
Expand Down Expand Up @@ -86,6 +77,6 @@ public boolean isDisposed() {

@Override
public boolean hasCustomOnError() {
return onError != this;
return onError != Functions.ON_ERROR_MISSING;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class CallbackCompletableObserverTest extends RxJavaTest {

@Test
public void emptyActionShouldReportNoCustomOnError() {
CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.EMPTY_ACTION);
CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.ON_ERROR_MISSING, Functions.EMPTY_ACTION);

assertFalse(o.hasCustomOnError());
}
Expand Down