File tree 1 file changed +7
-2
lines changed
tck/src/main/java/org/reactivestreams/tck
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -96,11 +96,16 @@ public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() t
96
96
@ Override
97
97
public void run (BlackboxTestStage stage ) throws InterruptedException {
98
98
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
100
101
101
102
// 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 ++)
103
104
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 ();
104
109
}
105
110
});
106
111
}
You can’t perform that action at this time.
0 commit comments