mirror of https://github.com/grpc/grpc-java.git
parent
446f0cb85f
commit
d9d4d8b70f
|
|
@ -87,7 +87,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<RespT> {
|
||||||
String encoding = inboundHeaders.get(MESSAGE_ENCODING_KEY);
|
String encoding = inboundHeaders.get(MESSAGE_ENCODING_KEY);
|
||||||
Decompressor decompressor = decompressorRegistry.lookupDecompressor(encoding);
|
Decompressor decompressor = decompressorRegistry.lookupDecompressor(encoding);
|
||||||
if (decompressor == null) {
|
if (decompressor == null) {
|
||||||
throw Status.INTERNAL
|
throw Status.UNIMPLEMENTED
|
||||||
.withDescription(String.format("Can't find decompressor for %s", encoding))
|
.withDescription(String.format("Can't find decompressor for %s", encoding))
|
||||||
.asRuntimeException();
|
.asRuntimeException();
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +233,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<RespT> {
|
||||||
}
|
}
|
||||||
// Special case for unary calls.
|
// Special case for unary calls.
|
||||||
if (messageReceived && call.method.getType() == MethodType.UNARY) {
|
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"),
|
"More than one request messages for unary call or server streaming call"),
|
||||||
new Metadata());
|
new Metadata());
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,7 @@ public class ServerCallImplTest {
|
||||||
verify(callListener).onMessage(1234L);
|
verify(callListener).onMessage(1234L);
|
||||||
|
|
||||||
verify(stream).close(statusCaptor.capture(), Mockito.isA(Metadata.class));
|
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
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public class ProtoUtils {
|
||||||
try {
|
try {
|
||||||
return new ByteArrayInputStream(printer.print(value).getBytes(charset));
|
return new ByteArrayInputStream(printer.print(value).getBytes(charset));
|
||||||
} catch (InvalidProtocolBufferException e) {
|
} catch (InvalidProtocolBufferException e) {
|
||||||
throw Status.INVALID_ARGUMENT
|
throw Status.INTERNAL
|
||||||
.withCause(e)
|
.withCause(e)
|
||||||
.withDescription("Unable to print json proto")
|
.withDescription("Unable to print json proto")
|
||||||
.asRuntimeException();
|
.asRuntimeException();
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ public class ServerCalls {
|
||||||
onReady();
|
onReady();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
call.close(Status.INVALID_ARGUMENT.withDescription("Half-closed without a request"),
|
call.close(Status.INTERNAL.withDescription("Half-closed without a request"),
|
||||||
new Metadata());
|
new Metadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,13 +84,13 @@ public class ClientCallsTest {
|
||||||
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
ArgumentCaptor<ClientCall.Listener<String>> listenerCaptor = ArgumentCaptor.forClass(null);
|
||||||
verify(call).start(listenerCaptor.capture(), any(Metadata.class));
|
verify(call).start(listenerCaptor.capture(), any(Metadata.class));
|
||||||
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
ClientCall.Listener<String> listener = listenerCaptor.getValue();
|
||||||
listener.onClose(Status.INVALID_ARGUMENT, new Metadata());
|
listener.onClose(Status.INTERNAL, new Metadata());
|
||||||
try {
|
try {
|
||||||
future.get();
|
future.get();
|
||||||
fail("Should fail");
|
fail("Should fail");
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
Status status = Status.fromThrowable(e.getCause());
|
Status status = Status.fromThrowable(e.getCause());
|
||||||
assertEquals(Status.INVALID_ARGUMENT, status);
|
assertEquals(Status.INTERNAL, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -556,7 +556,7 @@ public abstract class AbstractTransportTest {
|
||||||
ServerStreamListener mockServerStreamListener = serverStreamCreation.listener;
|
ServerStreamListener mockServerStreamListener = serverStreamCreation.listener;
|
||||||
|
|
||||||
Status status =
|
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());
|
serverStream.close(status, new Metadata());
|
||||||
verify(mockServerStreamListener, timeout(TIMEOUT_MS)).closed(statusCaptor.capture());
|
verify(mockServerStreamListener, timeout(TIMEOUT_MS)).closed(statusCaptor.capture());
|
||||||
assertCodeEquals(Status.OK, statusCaptor.getValue());
|
assertCodeEquals(Status.OK, statusCaptor.getValue());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue