Skip to content

Exception in onCompleted() not propagate to onError() #630

@ronanM

Description

@ronanM

When an exception occurred in onCompleted() the exception is not propagate to onError().

Code of rx.operators.SafeObserver

    @Override
    public void onCompleted() {
        if (isFinished.compareAndSet(false, true)) {
            try {
                actual.onCompleted();
            } catch (Throwable e) {
                // handle errors if the onCompleted implementation fails, not just if the Observable fails
                onError(e);
            }
            // auto-unsubscribe
            subscription.unsubscribe();
        }
    }

In our case isFinished is already TRUE, so onError does nothing.

 @Override
    public void onError(Throwable e) {
        if (isFinished.compareAndSet(false, true)) {
           ...
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions