Handle connection cancelling
This commit is contained in:
parent
b7172db2f9
commit
9ba2026265
@ -5,6 +5,7 @@ import static it.cavallium.rockserver.core.common.Utils.toMemorySegment;
|
|||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.Empty;
|
import com.google.protobuf.Empty;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
|
import io.grpc.StatusRuntimeException;
|
||||||
import io.grpc.netty.NettyServerBuilder;
|
import io.grpc.netty.NettyServerBuilder;
|
||||||
import io.grpc.stub.ServerCallStreamObserver;
|
import io.grpc.stub.ServerCallStreamObserver;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
@ -769,6 +770,11 @@ public class GrpcServer extends Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void handleError(StreamObserver<?> responseObserver, Throwable ex) {
|
private static void handleError(StreamObserver<?> responseObserver, Throwable ex) {
|
||||||
|
if (ex instanceof StatusRuntimeException e && e.getStatus().getCode().equals(Status.CANCELLED.getCode())) {
|
||||||
|
LOG.warn("Connection cancelled: {}", e.getStatus().getDescription());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ex instanceof CompletionException exx) {
|
if (ex instanceof CompletionException exx) {
|
||||||
handleError(responseObserver, exx.getCause());
|
handleError(responseObserver, exx.getCause());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user