You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Yuxuan Wang (Jira)" <ji...@apache.org> on 2022/02/23 19:08:00 UTC
[jira] [Updated] (THRIFT-5527) Compiler generated Process function in go will swallow exceptions defined in thrift IDL
[ https://issues.apache.org/jira/browse/THRIFT-5527?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuxuan Wang updated THRIFT-5527:
--------------------------------
Description:
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 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.
was:
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.
> 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
> Priority: Major
> Fix For: 0.17.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> 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 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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)