Skip to content
Merged
Changes from all commits
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
Ensure Subscriber is removed from sendingSubscriptions
Closes gh-961

Signed-off-by: Rossen Stoyanchev <rstoyanchev@vmware.com>
  • Loading branch information
rstoyanchev committed Nov 23, 2020
commit ae94de01c4b52d3e6a55beeee485c97eafd7fc73
16 changes: 6 additions & 10 deletions rsocket-core/src/main/java/io/rsocket/core/RSocketResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,22 +406,20 @@ private void handleRequestResponse(int streamId, Mono<Payload> response) {

@Override
protected void hookOnNext(Payload payload) {
if (isEmpty) {
isEmpty = false;
}
isEmpty = false;

if (!PayloadValidationUtils.isValid(mtu, payload, maxFrameLength)) {
payload.release();
cancel();
final IllegalArgumentException t =
new IllegalArgumentException(INVALID_PAYLOAD_ERROR_MESSAGE);
handleError(streamId, t);
sendingSubscriptions.remove(streamId, this);
handleError(streamId, new IllegalArgumentException(INVALID_PAYLOAD_ERROR_MESSAGE));
return;
}

ByteBuf byteBuf =
PayloadFrameCodec.encodeNextCompleteReleasingPayload(allocator, streamId, payload);
sendProcessor.onNext(byteBuf);
sendingSubscriptions.remove(streamId, this);
}

@Override
Expand All @@ -433,10 +431,8 @@ protected void hookOnError(Throwable throwable) {

@Override
protected void hookOnComplete() {
if (isEmpty) {
if (sendingSubscriptions.remove(streamId, this)) {
sendProcessor.onNext(PayloadFrameCodec.encodeComplete(allocator, streamId));
}
if (isEmpty && sendingSubscriptions.remove(streamId, this)) {
sendProcessor.onNext(PayloadFrameCodec.encodeComplete(allocator, streamId));
}
}
};
Expand Down