Merge pull request #752 from printfcoder/master

recover gPRC handler if panic
This commit is contained in:
Asim Aslam 2019-09-11 09:10:30 -07:00 committed by GitHub
commit 988603f87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -338,6 +338,11 @@ func (g *grpcServer) processRequest(stream grpc.ServerStream, service *service,
// define the handler func // define the handler func
fn := func(ctx context.Context, req server.Request, rsp interface{}) error { fn := func(ctx context.Context, req server.Request, rsp interface{}) error {
defer func() {
if r := recover(); r != nil {
log.Logf("handler %s panic recovered, err: %s", mtype.method.Name, r)
}
}()
returnValues = function.Call([]reflect.Value{service.rcvr, mtype.prepareContext(ctx), reflect.ValueOf(argv.Interface()), reflect.ValueOf(rsp)}) returnValues = function.Call([]reflect.Value{service.rcvr, mtype.prepareContext(ctx), reflect.ValueOf(argv.Interface()), reflect.ValueOf(rsp)})
// The return value for the method is an error. // The return value for the method is an error.