Skip to content

Commit 1024a7f

Browse files
committed
11246:: addressing the review comments.
1 parent bb929aa commit 1024a7f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.grpc.ServerServiceDefinition;
5757
import io.grpc.ServerTransportFilter;
5858
import io.grpc.Status;
59+
import io.grpc.StatusException;
5960
import io.grpc.StatusRuntimeException;
6061
import io.perfmark.Link;
6162
import io.perfmark.PerfMark;
@@ -813,10 +814,14 @@ private void internalClose(Throwable t) {
813814
// TODO(ejona86): this is not thread-safe :)
814815
String description = "Application error processing RPC";
815816
Status statusToPropagate = Status.UNKNOWN.withDescription(description).withCause(t);
817+
Status extractedStatus = null;
816818
if (t instanceof StatusRuntimeException) {
817-
if (((StatusRuntimeException) t).getStatus().getCode() == Status.Code.RESOURCE_EXHAUSTED) {
818-
statusToPropagate = ((StatusRuntimeException) t).getStatus().withCause(t);
819-
}
819+
extractedStatus = ((StatusRuntimeException) t).getStatus();
820+
} else if (t instanceof StatusException) {
821+
extractedStatus = ((StatusException) t).getStatus();
822+
}
823+
if (extractedStatus != null && extractedStatus.getCode() == Status.Code.RESOURCE_EXHAUSTED) {
824+
statusToPropagate = extractedStatus.withCause(t);
820825
}
821826
stream.close(statusToPropagate, new Metadata());
822827
}

0 commit comments

Comments
 (0)