Skip to content

Commit 80baa63

Browse files
committed
Use return value of Status.augmentDescription
1 parent dda4ad7 commit 80baa63

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

netty/src/main/java/io/grpc/netty/NettyClientHandler.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ private void cancelPing(Throwable t) {
499499
}
500500

501501
private Status statusFromGoAway(long errorCode, byte[] debugData) {
502-
Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode);
503-
status.augmentDescription("Received Goaway");
502+
Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode)
503+
.augmentDescription("Received Goaway");
504504
if (debugData != null && debugData.length > 0) {
505505
// If a debug message was provided, use it.
506506
String msg = new String(debugData, UTF_8);

netty/src/test/java/io/grpc/netty/NettyClientHandlerTest.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import io.grpc.StatusException;
6262
import io.grpc.internal.ClientTransport;
6363
import io.grpc.internal.ClientTransport.PingCallback;
64-
import io.grpc.internal.GrpcUtil;
6564
import io.netty.buffer.ByteBuf;
6665
import io.netty.buffer.ByteBufUtil;
6766
import io.netty.buffer.Unpooled;
@@ -271,7 +270,8 @@ public void receivedGoAwayShouldCancelBufferedStream() throws Exception {
271270
assertTrue(future.isDone());
272271
assertFalse(future.isSuccess());
273272
Status status = Status.fromThrowable(future.cause());
274-
assertEquals(GrpcUtil.Http2Error.NO_ERROR.status(), status);
273+
assertEquals(Status.Code.UNAVAILABLE, status.getCode());
274+
assertEquals("HTTP/2 error code: NO_ERROR\nReceived Goaway", status.getDescription());
275275
}
276276

277277
@Test
@@ -284,7 +284,7 @@ public void receivedGoAwayShouldFailUnknownStreams() throws Exception {
284284
verify(stream).transportReportStatus(captor.capture(), eq(false),
285285
notNull(Metadata.class));
286286
assertEquals(Status.CANCELLED.getCode(), captor.getValue().getCode());
287-
assertEquals("HTTP/2 error code: CANCEL\nthis is a test",
287+
assertEquals("HTTP/2 error code: CANCEL\nReceived Goaway\nthis is a test",
288288
captor.getValue().getDescription());
289289
}
290290

@@ -300,7 +300,8 @@ public void receivedGoAwayShouldFailUnknownBufferedStreams() throws Exception {
300300
assertFalse(future.isSuccess());
301301
Status status = Status.fromThrowable(future.cause());
302302
assertEquals(Status.CANCELLED.getCode(), status.getCode());
303-
assertEquals("HTTP/2 error code: CANCEL\nthis is a test", status.getDescription());
303+
assertEquals("HTTP/2 error code: CANCEL\nReceived Goaway\nthis is a test",
304+
status.getDescription());
304305
}
305306

306307
@Test
@@ -314,7 +315,8 @@ public void receivedGoAwayShouldFailNewStreams() throws Exception {
314315
assertFalse(future.isSuccess());
315316
Status status = Status.fromThrowable(future.cause());
316317
assertEquals(Status.CANCELLED.getCode(), status.getCode());
317-
assertEquals("HTTP/2 error code: CANCEL\nthis is a test", status.getDescription());
318+
assertEquals("HTTP/2 error code: CANCEL\nReceived Goaway\nthis is a test",
319+
status.getDescription());
318320
}
319321

320322
@Test

okhttp/src/main/java/io/grpc/okhttp/OkHttpClientTransport.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,11 @@ public void ackSettings() {
785785

786786
@Override
787787
public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
788-
Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode);
789-
status.augmentDescription("Received Goaway");
788+
Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode)
789+
.augmentDescription("Received Goaway");
790790
if (debugData != null && debugData.size() > 0) {
791791
// If a debug message was provided, use it.
792-
status.augmentDescription(debugData.utf8());
792+
status = status.augmentDescription(debugData.utf8());
793793
}
794794
startGoAway(lastGoodStreamId, status);
795795
}

0 commit comments

Comments
 (0)