Skip to content

Commit 50197f1

Browse files
committed
Synchronously mark the call as cancelled by calling closedInternal to avoid races with more messages or halfClose after the error scenario was observed.
1 parent 553b33a commit 50197f1

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

core/src/main/java/io/grpc/internal/ServerCallImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ private void messagesAvailableInternal(final MessageProducer producer) {
355355
call.stream.cancel(Status.INTERNAL.withDescription("Too many requests"));
356356
GrpcUtil.closeQuietly(delayedMessage);
357357
delayedMessage = null;
358+
closedInternal(Status.INTERNAL.withDescription("Too many requests"));
358359
return;
359360
}
360361
try {

core/src/test/java/io/grpc/internal/ServerCallImplTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ public void streamListener_messageRead_unary_tooManyRequests() {
573573

574574
verify(stream).cancel(any(Status.class));
575575
verify(callListener, never()).onMessage(any(Long.class));
576+
verify(callListener).onCancel();
577+
assertTrue(context.isCancelled());
576578
}
577579

578580
@Test

0 commit comments

Comments
 (0)