Skip to content

Commit

Permalink
fix: backport fix for cancellation in Uni to Multi bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Feb 21, 2024
1 parent 105b819 commit 607320e
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@ public Context context() {

@Override
public void cancel() {
if (upstream != null) {
upstream.cancel();
if (STATE_UPDATER.getAndSet(this, State.DONE) != State.DONE) {
if (upstream != null) {
upstream.cancel();
}
}
}

@Override
public void request(long n) {
if (n <= 0L) {
downstream.onError(new IllegalArgumentException("Invalid request"));
return;
}
if (STATE_UPDATER.compareAndSet(this, State.INIT, State.UNI_REQUESTED)) {
AbstractUni.subscribe(uni, this);
if (n <= 0L) {
onFailure(new IllegalArgumentException("Invalid request"));
} else {
AbstractUni.subscribe(uni, this);
}
}
}

Expand Down

0 comments on commit 607320e

Please sign in to comment.