mirror of https://github.com/grpc/grpc-java.git
netty: fix status message when GOAWAY at MAX_CONCURRENT_STREAMS limit
Resolves #8097
This commit is contained in:
parent
49f9380fc9
commit
eb6764841b
|
|
@ -570,17 +570,23 @@ class NettyClientHandler extends AbstractNettyHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (connection().goAwayReceived()) {
|
if (connection().goAwayReceived()) {
|
||||||
if (streamId > connection().local().lastStreamKnownByPeer()
|
Status s = abruptGoAwayStatus;
|
||||||
|| connection().local().numActiveStreams() == connection().local().maxActiveStreams()) {
|
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
|
// This should only be reachable during onGoAwayReceived, as otherwise
|
||||||
// getShutdownThrowable() != null
|
// getShutdownThrowable() != null
|
||||||
command.stream().setNonExistent();
|
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());
|
command.stream().transportReportStatus(s, RpcProgress.REFUSED, true, new Metadata());
|
||||||
promise.setFailure(s.asRuntimeException());
|
promise.setFailure(s.asRuntimeException());
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -378,7 +378,7 @@ public class NettyClientHandlerTest extends NettyHandlerTestBase<NettyClientHand
|
||||||
assertEquals(Status.UNAVAILABLE.getCode(), captor.getValue().getCode());
|
assertEquals(Status.UNAVAILABLE.getCode(), captor.getValue().getCode());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Abrupt GOAWAY closed unsent stream. HTTP/2 error code: CANCEL, "
|
"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());
|
captor.getValue().getDescription());
|
||||||
assertTrue(future.isDone());
|
assertTrue(future.isDone());
|
||||||
}
|
}
|
||||||
|
|
@ -411,6 +411,8 @@ public class NettyClientHandlerTest extends NettyHandlerTestBase<NettyClientHand
|
||||||
assertThat(Status.fromThrowable(future2.cause()).getCode()).isEqualTo(Status.Code.UNAVAILABLE);
|
assertThat(Status.fromThrowable(future2.cause()).getCode()).isEqualTo(Status.Code.UNAVAILABLE);
|
||||||
assertThat(future2.cause().getMessage()).contains(
|
assertThat(future2.cause().getMessage()).contains(
|
||||||
"Abrupt GOAWAY closed unsent stream. HTTP/2 error code: NO_ERROR");
|
"Abrupt GOAWAY closed unsent stream. HTTP/2 error code: NO_ERROR");
|
||||||
|
assertThat(future2.cause().getMessage()).contains(
|
||||||
|
"At MAX_CONCURRENT_STREAMS limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue