Skip to content

fixes RequestOperator to subscribe to the source at later phase #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class RequestOperator
Fuseable.QueueSubscription<Payload>,
Fuseable {

final CorePublisher<Payload> source;
final String errorMessageOnSecondSubscription;

CoreSubscriber<? super Payload> actual;
Expand All @@ -38,8 +39,8 @@ abstract class RequestOperator
AtomicIntegerFieldUpdater.newUpdater(RequestOperator.class, "wip");

RequestOperator(CorePublisher<Payload> source, String errorMessageOnSecondSubscription) {
this.source = source;
this.errorMessageOnSecondSubscription = errorMessageOnSecondSubscription;
source.subscribe(this);
WIP.lazySet(this, -1);
}

Expand All @@ -52,6 +53,7 @@ public void subscribe(Subscriber<? super Payload> actual) {
public void subscribe(CoreSubscriber<? super Payload> actual) {
if (this.wip == -1 && WIP.compareAndSet(this, -1, 0)) {
this.actual = actual;
source.subscribe(this);
actual.onSubscribe(this);
} else {
Operators.error(actual, new IllegalStateException(this.errorMessageOnSecondSubscription));
Expand Down