Skip to content

=tck #362 signal onComplete in 201 blackbox verification #372

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 2 commits into from
Jun 16, 2017
Merged
Changes from 1 commit
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 @@ -96,11 +96,16 @@ public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() t
@Override
public void run(BlackboxTestStage stage) throws InterruptedException {
triggerRequest(stage.subProxy().sub());
final long n = stage.expectRequest();// assuming subscriber wants to consume elements...
final long requested = stage.expectRequest();// assuming subscriber wants to consume elements...
final long signalsToEmit = Math.min(requested, 512); // protecting against Subscriber which sends ridiculous large demand
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or could be TestEnvironment.TEST_BUFFER_SIZE, anything less than huge numbers is fine here though IMO


// should cope with up to requested number of elements
for (int i = 0; i < n; i++)
for (int i = 0; i < signalsToEmit; i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also check if the Subscriber signalled cancel and not loop unnecessarily.

stage.signalNext();

// we complete after `signalsToEmit` (which can be less than `requested`),
// which is legal under https://github.com/reactive-streams/reactive-streams-jvm#1.2
stage.sendCompletion();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we sendCompletion() even if cancelled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? Cancellation is allowed to be "racy"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the "polite" implementation would check if it is not cancelled before issuing the completion. (so that the implementation does not rely on onComplete if cancelled)

}
});
}
Expand Down