Skip to content

Commit 5fc82d7

Browse files
committed
=tck reactive-streams#362 signal onComplete in 201 blackbox verification
1 parent 2879ce0 commit 5fc82d7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tck/src/main/java/org/reactivestreams/tck/SubscriberBlackboxVerification.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,16 @@ public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() t
9696
@Override
9797
public void run(BlackboxTestStage stage) throws InterruptedException {
9898
triggerRequest(stage.subProxy().sub());
99-
final long n = stage.expectRequest();// assuming subscriber wants to consume elements...
99+
final long requested = stage.expectRequest();// assuming subscriber wants to consume elements...
100+
final long signalsToEmit = Math.min(requested, 512); // protecting against Subscriber which sends ridiculous large demand
100101

101102
// should cope with up to requested number of elements
102-
for (int i = 0; i < n; i++)
103+
for (int i = 0; i < signalsToEmit; i++)
103104
stage.signalNext();
105+
106+
// we complete after `signalsToEmit` (which can be less than `requested`),
107+
// which is legal under https://github.com/reactive-streams/reactive-streams-jvm#1.2
108+
stage.sendCompletion();
104109
}
105110
});
106111
}

0 commit comments

Comments
 (0)