Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 14 additions & 8 deletions netty/src/main/java/io/grpc/netty/NettyClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,23 @@ private void createStream(CreateStreamCommand command, ChannelPromise promise)
return;
}
if (connection().goAwayReceived()) {
if (streamId > connection().local().lastStreamKnownByPeer()
|| connection().local().numActiveStreams() == connection().local().maxActiveStreams()) {
Status s = abruptGoAwayStatus;
int maxActiveStreams = connection().local().maxActiveStreams();
int lastStreamId = connection().local().lastStreamKnownByPeer();
if (s == null) {
// Should be impossible, but handle pseudo-gracefully
s = Status.INTERNAL.withDescription(
"Failed due to abrupt GOAWAY, but can't find GOAWAY details");
} else if (streamId > lastStreamId) {
s = s.augmentDescription(
"stream id: " + streamId + ", GOAWAY Last-Stream-ID:" + lastStreamId);
} else if (connection().local().numActiveStreams() == maxActiveStreams) {
s = s.augmentDescription("At MAX_CONCURRENT_STREAMS limit. limit: " + maxActiveStreams);
}
if (streamId > lastStreamId || connection().local().numActiveStreams() == maxActiveStreams) {
// This should only be reachable during onGoAwayReceived, as otherwise
// getShutdownThrowable() != null
command.stream().setNonExistent();
Status s = abruptGoAwayStatus;
if (s == null) {
// Should be impossible, but handle psuedo-gracefully
s = Status.INTERNAL.withDescription(
"Failed due to abrupt GOAWAY, but can't find GOAWAY details");
}
command.stream().transportReportStatus(s, RpcProgress.REFUSED, true, new Metadata());
promise.setFailure(s.asRuntimeException());
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public void receivedAbruptGoAwayShouldFailRacingQueuedStreamid() throws Exceptio
assertEquals(Status.UNAVAILABLE.getCode(), captor.getValue().getCode());
assertEquals(
"Abrupt GOAWAY closed unsent stream. HTTP/2 error code: CANCEL, "
+ "debug data: this is a test",
+ "debug data: this is a test\nstream id: 3, GOAWAY Last-Stream-ID:0",
captor.getValue().getDescription());
assertTrue(future.isDone());
}
Expand Down Expand Up @@ -411,6 +411,8 @@ public void receivedGoAway_shouldFailBufferedStreamsExceedingMaxConcurrentStream
assertThat(Status.fromThrowable(future2.cause()).getCode()).isEqualTo(Status.Code.UNAVAILABLE);
assertThat(future2.cause().getMessage()).contains(
"Abrupt GOAWAY closed unsent stream. HTTP/2 error code: NO_ERROR");
assertThat(future2.cause().getMessage()).contains(
"At MAX_CONCURRENT_STREAMS limit");
}

@Test
Expand Down