Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5527

Compiler generated Process function in go will swallow exceptions defined in thrift IDL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.16.0
    • 0.17.0
    • Go - Compiler
    • None

    Description

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

      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
      

      so, when a handler 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.

      Attachments

        Issue Links

          Activity

            People

              fishywang Yuxuan Wang
              fishywang Yuxuan Wang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m