core: add description to Status.UNKNOWN in ServerImpl's #internalClose (#10643)

This is currently the only place where we return Status.UNKNOWN with no description, which makes is harder to debug and differentiate from statuses originated from non-grpc sources.

This PR enriches ServerImpl's #internalClose `Status.UNKNOWN` with description `Application error processing RPC`.
This commit is contained in:
Sergii Tkachenko 2023-11-06 12:31:30 -08:00 committed by GitHub
parent 15fc70be2a
commit 8b4b14ac40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -810,7 +810,8 @@ public final class ServerImpl extends io.grpc.Server implements InternalInstrume
*/
private void internalClose(Throwable t) {
// TODO(ejona86): this is not thread-safe :)
stream.close(Status.UNKNOWN.withCause(t), new Metadata());
String description = "Application error processing RPC";
stream.close(Status.UNKNOWN.withDescription(description).withCause(t), new Metadata());
}
@Override

View File

@ -249,7 +249,11 @@ public class MoreInProcessTest {
.onNext(StreamingInputCallRequest.getDefaultInstance());
assertTrue(finishLatch.await(900, TimeUnit.MILLISECONDS));
assertEquals(Status.UNKNOWN, Status.fromThrowable(throwableRef.get()));
Status actualStatus = Status.fromThrowable(throwableRef.get());
Status expectedStatus = Status.UNKNOWN.withDescription("Application error processing RPC");
assertEquals(expectedStatus.getCode(), actualStatus.getCode());
assertEquals(expectedStatus.getDescription(), actualStatus.getDescription());
assertNull(actualStatus.getCause());
assertNull(responseRef.get());
}
}