Skip to content
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

ensures there is no extra logging about a dropped error #859

Merged
merged 1 commit into from
Jun 4, 2020
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
52 changes: 20 additions & 32 deletions rsocket-core/src/main/java/io/rsocket/core/RSocketResponder.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,19 @@ protected void hookOnNext(Payload payload) {

@Override
protected void hookOnError(Throwable throwable) {
handleError(streamId, throwable);
if (sendingSubscriptions.remove(streamId, this)) {
handleError(streamId, throwable);
}
}

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

@Override
protected void hookFinally(SignalType type) {
sendingSubscriptions.remove(streamId, this);
}
};

sendingSubscriptions.put(streamId, subscriber);
Expand Down Expand Up @@ -491,36 +490,17 @@ protected void hookOnNext(Payload payload) {

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

@Override
protected void hookOnError(Throwable throwable) {
handleError(streamId, throwable);
}

@Override
protected void hookOnCancel() {
// specifically for requestChannel case so when requester sends Cancel frame so the
// whole chain MUST be terminated
// Note: CancelFrame is redundant from the responder side due to spec
// (https://github.com/rsocket/rsocket/blob/master/Protocol.md#request-channel)
// Upon receiving a CANCEL, the stream is terminated on the Responder.
// Upon sending a CANCEL, the stream is terminated on the Requester.
if (requestChannel != null) {
channelProcessors.remove(streamId, requestChannel);
try {
requestChannel.dispose();
} catch (Exception e) {
// might be thrown back if stream is cancelled
}
if (sendingSubscriptions.remove(streamId, this)) {
handleError(streamId, throwable);
}
}

@Override
protected void hookFinally(SignalType type) {
sendingSubscriptions.remove(streamId);
}
};

sendingSubscriptions.put(streamId, subscriber);
Expand Down Expand Up @@ -588,7 +568,15 @@ protected void hookOnError(Throwable throwable) {}

private void handleCancelFrame(int streamId) {
Subscription subscription = sendingSubscriptions.remove(streamId);
channelProcessors.remove(streamId);
Processor<Payload, Payload> processor = channelProcessors.remove(streamId);

if (processor != null) {
try {
processor.onError(new CancellationException("Disposed"));
} catch (Exception e) {
// ignore
}
}

if (subscription != null) {
subscription.cancel();
Expand Down