Skip to content

Commit d9d4d8b

Browse files
author
nmittler
committed
Updating status codes to match the spec.
Fixes grpc#1605
1 parent 446f0cb commit d9d4d8b

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<RespT> {
8787
String encoding = inboundHeaders.get(MESSAGE_ENCODING_KEY);
8888
Decompressor decompressor = decompressorRegistry.lookupDecompressor(encoding);
8989
if (decompressor == null) {
90-
throw Status.INTERNAL
90+
throw Status.UNIMPLEMENTED
9191
.withDescription(String.format("Can't find decompressor for %s", encoding))
9292
.asRuntimeException();
9393
}
@@ -233,7 +233,7 @@ public void messageRead(final InputStream message) {
233233
}
234234
// Special case for unary calls.
235235
if (messageReceived && call.method.getType() == MethodType.UNARY) {
236-
call.stream.close(Status.INVALID_ARGUMENT.withDescription(
236+
call.stream.close(Status.INTERNAL.withDescription(
237237
"More than one request messages for unary call or server streaming call"),
238238
new Metadata());
239239
return;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void streamListener_messageRead_unaryFailsOnMultiple() {
276276
verify(callListener).onMessage(1234L);
277277

278278
verify(stream).close(statusCaptor.capture(), Mockito.isA(Metadata.class));
279-
assertEquals(Status.Code.INVALID_ARGUMENT, statusCaptor.getValue().getCode());
279+
assertEquals(Status.Code.INTERNAL, statusCaptor.getValue().getCode());
280280
}
281281

282282
@Test

protobuf/src/main/java/io/grpc/protobuf/ProtoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public InputStream stream(T value) {
8989
try {
9090
return new ByteArrayInputStream(printer.print(value).getBytes(charset));
9191
} catch (InvalidProtocolBufferException e) {
92-
throw Status.INVALID_ARGUMENT
92+
throw Status.INTERNAL
9393
.withCause(e)
9494
.withDescription("Unable to print json proto")
9595
.asRuntimeException();

stub/src/main/java/io/grpc/stub/ServerCalls.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void onHalfClose() {
156156
onReady();
157157
}
158158
} else {
159-
call.close(Status.INVALID_ARGUMENT.withDescription("Half-closed without a request"),
159+
call.close(Status.INTERNAL.withDescription("Half-closed without a request"),
160160
new Metadata());
161161
}
162162
}

stub/src/test/java/io/grpc/stub/ClientCallsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public class ClientCallsTest {
8484
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
8585
verify(call).start(listenerCaptor.capture(), any(Metadata.class));
8686
ClientCall.Listener<String> listener = listenerCaptor.getValue();
87-
listener.onClose(Status.INVALID_ARGUMENT, new Metadata());
87+
listener.onClose(Status.INTERNAL, new Metadata());
8888
try {
8989
future.get();
9090
fail("Should fail");
9191
} catch (ExecutionException e) {
9292
Status status = Status.fromThrowable(e.getCause());
93-
assertEquals(Status.INVALID_ARGUMENT, status);
93+
assertEquals(Status.INTERNAL, status);
9494
}
9595
}
9696

testing/src/main/java/io/grpc/internal/testing/AbstractTransportTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ public void earlyServerClose_serverFailure() throws Exception {
556556
ServerStreamListener mockServerStreamListener = serverStreamCreation.listener;
557557

558558
Status status =
559-
Status.INVALID_ARGUMENT.withDescription("I'm not listening").withCause(new Exception());
559+
Status.INTERNAL.withDescription("I'm not listening").withCause(new Exception());
560560
serverStream.close(status, new Metadata());
561561
verify(mockServerStreamListener, timeout(TIMEOUT_MS)).closed(statusCaptor.capture());
562562
assertCodeEquals(Status.OK, statusCaptor.getValue());

0 commit comments

Comments
 (0)