Yuxuan Wang created THRIFT-5527:
-----------------------------------

             Summary: Compiler generated Process function in go will swallow 
exceptions defined in thrift IDL
                 Key: THRIFT-5527
                 URL: https://issues.apache.org/jira/browse/THRIFT-5527
             Project: Thrift
          Issue Type: Bug
          Components: Go - Compiler
    Affects Versions: 0.16.0
            Reporter: Yuxuan Wang
            Assignee: Yuxuan Wang


This is an example snippet generated by the current version of compiler:

{code:go}
result := ResultType{}
var retval *ResponseType
if retval, err2 = p.handler.Handler(ctx, args.Request); err2 != nil {
        tickerCancel()
        switch v := err2.(type) {
        case *ThriftIDLDefinedExceptionType:
                result.Err = v
        default:
                if err2 == thrift.ErrAbandonRequest {
                        return false, thrift.WrapTException(err2)
                }
                x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, 
"Internal error processing authenticateCookie: "+err2.Error())
                oprot.WriteMessageBegin(ctx, "handler", thrift.EXCEPTION, seqId)
                x.Write(ctx, oprot)
                oprot.WriteMessageEnd(ctx)
                oprot.Flush(ctx)
                return true, thrift.WrapTException(err2)
        }
} else {
        result.Success = retval
}
tickerCancel()
if err3 := oprot.WriteMessageBegin(ctx, "handler", thrift.REPLY, seqId); err3 
!= nil {
        err = thrift.WrapTException(err3)
}
if err4 := result.Write(ctx, oprot); err == nil && err4 != nil {
        err = thrift.WrapTException(err4)
}
if err5 := oprot.WriteMessageEnd(ctx); err == nil && err5 != nil {
        err = thrift.WrapTException(err5)
}
if err6 := oprot.Flush(ctx); err == nil && err6 != nil {
        err = thrift.WrapTException(err6)
}
if err != nil {
        return
}
return true, err
{code}

so, when a handle returns ThriftIDLDefinedExceptionType exception, the Process 
function would only return an error if it fails to write the exception to the 
wire, and nil-error if the writing was successful. This will cause the 
processer middlewares unable to access any exceptions defined in thrift IDLs.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to