Updating status codes to match the spec.

Fixes #1605
This commit is contained in:
nmittler 2016-05-09 09:58:11 -07:00
parent 446f0cb85f
commit d9d4d8b70f
6 changed files with 8 additions and 8 deletions

View File

@ -87,7 +87,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<RespT> {
String encoding = inboundHeaders.get(MESSAGE_ENCODING_KEY);
Decompressor decompressor = decompressorRegistry.lookupDecompressor(encoding);
if (decompressor == null) {
throw Status.INTERNAL
throw Status.UNIMPLEMENTED
.withDescription(String.format("Can't find decompressor for %s", encoding))
.asRuntimeException();
}
@ -233,7 +233,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<RespT> {
}
// Special case for unary calls.
if (messageReceived && call.method.getType() == MethodType.UNARY) {
call.stream.close(Status.INVALID_ARGUMENT.withDescription(
call.stream.close(Status.INTERNAL.withDescription(
"More than one request messages for unary call or server streaming call"),
new Metadata());
return;

View File

@ -276,7 +276,7 @@ public class ServerCallImplTest {
verify(callListener).onMessage(1234L);
verify(stream).close(statusCaptor.capture(), Mockito.isA(Metadata.class));
assertEquals(Status.Code.INVALID_ARGUMENT, statusCaptor.getValue().getCode());
assertEquals(Status.Code.INTERNAL, statusCaptor.getValue().getCode());
}
@Test

View File

@ -89,7 +89,7 @@ public class ProtoUtils {
try {
return new ByteArrayInputStream(printer.print(value).getBytes(charset));
} catch (InvalidProtocolBufferException e) {
throw Status.INVALID_ARGUMENT
throw Status.INTERNAL
.withCause(e)
.withDescription("Unable to print json proto")
.asRuntimeException();

View File

@ -156,7 +156,7 @@ public class ServerCalls {
onReady();
}
} else {
call.close(Status.INVALID_ARGUMENT.withDescription("Half-closed without a request"),
call.close(Status.INTERNAL.withDescription("Half-closed without a request"),
new Metadata());
}
}

View File

@ -84,13 +84,13 @@ public class ClientCallsTest {
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
verify(call).start(listenerCaptor.capture(), any(Metadata.class));
ClientCall.Listener<String> listener = listenerCaptor.getValue();
listener.onClose(Status.INVALID_ARGUMENT, new Metadata());
listener.onClose(Status.INTERNAL, new Metadata());
try {
future.get();
fail("Should fail");
} catch (ExecutionException e) {
Status status = Status.fromThrowable(e.getCause());
assertEquals(Status.INVALID_ARGUMENT, status);
assertEquals(Status.INTERNAL, status);
}
}

View File

@ -556,7 +556,7 @@ public abstract class AbstractTransportTest {
ServerStreamListener mockServerStreamListener = serverStreamCreation.listener;
Status status =
Status.INVALID_ARGUMENT.withDescription("I'm not listening").withCause(new Exception());
Status.INTERNAL.withDescription("I'm not listening").withCause(new Exception());
serverStream.close(status, new Metadata());
verify(mockServerStreamListener, timeout(TIMEOUT_MS)).closed(statusCaptor.capture());
assertCodeEquals(Status.OK, statusCaptor.getValue());