[
https://issues.apache.org/jira/browse/THRIFT-3533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15109453#comment-15109453
]
Jens Geyer commented on THRIFT-3533:
------------------------------------
I don't know. I understand the idea (after staring at it way too long), but the
implementation feels strange. As you said, the generator now generates
{{IsSet()}} for all fields, even the required ones. It suddenly becomes clear
when you start to realize, that {{IsSet()}} really should be named
{{IsThisInstanceValidAndTheMemberSet()}} because that's what it does. But even
then it is strange, because the code is still like this:
{code}
func (p *AuroraSchedulerManagerCreateJobArgs) Write(oprot thrift.TProtocol)
error {
// Note that at this point we may have p == null, but let's see how far
we can go ...
// p not used here, so we're lucky
if err := oprot.WriteStructBegin("createJob_args"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin
error: ", p), err)
}
// This is the first place where p != nil is actually tested. Can you
see it?
if err := p.writeField1(oprot); err != nil {
return err
}
// second place where p != nil is tested
if err := p.writeField3(oprot); err != nil {
return err
}
// another place where p != nil is tested
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
// p not used here, so we're lucky
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
// yippie, we're through!
return nil
}
{code}
That just looks strange to me.
@all: Any opinions form other Go'ers?
> Can not send nil pointer as service method argument
> ---------------------------------------------------
>
> Key: THRIFT-3533
> URL: https://issues.apache.org/jira/browse/THRIFT-3533
> Project: Thrift
> Issue Type: Bug
> Components: Go - Compiler
> Affects Versions: 0.9.3
> Reporter: Chris Bannister
> Attachments: 0001-go-compiler-handle-nil-fields-correctly.patch
>
>
> If you try to send a nil struct as an argument to a service method a panic
> occurs as it tries to write out all the fields in the struct, the python
> generated code has guarding 'if self.x != None:' for every struct field,
> whereas Go only outputs the 'if p.IsSet()' when the field is declared
> optional, which is not possible for argument lists.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)