Skip to content

Commit 33a0261

Browse files
committed
Responder: fix bug in Channel request-n
Check the value of request-n before asking the requester n-1 items, it was possible to request 0 items.
1 parent 0dd9a84 commit 33a0261

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/io/reactivesocket/internal/Responder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,11 @@ public void request(long n) {
716716
// after we are first subscribed to then send
717717
// the initial frame
718718
s.onNext(requestFrame);
719-
// initial requestN back to the requester (subtract 1
720-
// for the initial frame which was already sent)
721-
child.onNext(
722-
Frame.RequestN.from(streamId, rn.intValue() - 1));
719+
if (rn.intValue() > 0) {
720+
// initial requestN back to the requester (subtract 1
721+
// for the initial frame which was already sent)
722+
child.onNext(Frame.RequestN.from(streamId, rn.intValue() - 1));
723+
}
723724
}, r -> {
724725
// requested
725726
child.onNext(Frame.RequestN.from(streamId, r.intValue()));

0 commit comments

Comments
 (0)